From: Andre Noll Date: Sat, 22 Jan 2011 13:23:14 +0000 (+0100) Subject: init_rbtrees(): Fix initialization of volatile objects. X-Git-Tag: v0.1.2~4 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=83466429374f5036d9872f9905837f547967b0d5;p=osl.git 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. --- 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; }