]> git.tue.mpg.de Git - osl.git/commitdiff
init_rbtrees(): Fix initialization of volatile objects.
authorAndre Noll <maan@systemlinux.org>
Sat, 22 Jan 2011 13:23:14 +0000 (14:23 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 22 Jan 2011 13:23:14 +0000 (14:23 +0100)
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

diff --git a/osl.c b/osl.c
index d12b6b25ed00958172ef6102eb9cee4bf1030a70..67160d2b3bb14539edf1cd5f8b886d55940d0f63 100644 (file)
--- 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;
        }