From 83466429374f5036d9872f9905837f547967b0d5 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 22 Jan 2011 14:23:14 +0100 Subject: [PATCH 1/1] init_rbtrees(): Fix initialization of volatile objects. In case a table contains both volatile and non-volatile rbtree columns we must inititalize the arrray of pointers to the volatile objects. Without this patch, re-opening a non-empty table leads to a segfault. --- osl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osl.c b/osl.c index d12b6b2..67160d2 100644 --- a/osl.c +++ b/osl.c @@ -1045,6 +1045,7 @@ int init_rbtrees(struct osl_table *t) /* add valid rows to rbtrees */ t->num_invalid_rows = 0; for (i = 0; i < t->num_rows; i++) { + struct osl_object *volatile_objs; ret = row_is_invalid(t, i); if (ret < 0) return ret; @@ -1052,7 +1053,14 @@ int init_rbtrees(struct osl_table *t) t->num_invalid_rows++; continue; } - ret = add_row_to_rbtrees(t, i, NULL, NULL); + if (t->num_volatile_columns > 0) { + volatile_objs = calloc(t->num_volatile_columns, + sizeof(struct osl_object)); + if (!volatile_objs) + return -E_OSL_NOMEM; + } else + volatile_objs = NULL; + ret = add_row_to_rbtrees(t, i, volatile_objs, NULL); if (ret < 0) return ret; } -- 2.39.2