From: John Darrington Date: Sat, 27 Oct 2007 07:12:40 +0000 (+0000) Subject: Fixed bugs #21397 and 21330 X-Git-Tag: v0.6.0~213 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=103646b53527f82c291f317b660ca395f0b50f0c;p=pspp-builds.git Fixed bugs #21397 and 21330 --- diff --git a/src/data/ChangeLog b/src/data/ChangeLog index a8f897ef..ad2d8287 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,9 @@ +2007-10-27 John Darrington + + * dictionary.c: Fixed bug in dict_clone, where the vardict.dict member + wasn't initialised correctly. Closes bugs #21330 and 21397 + + 2007-10-08 Ben Pfaff Fix bug #21280. Thanks to John Darrington for review. diff --git a/src/data/dictionary.c b/src/data/dictionary.c index 32e9840b..0f3e25e3 100644 --- a/src/data/dictionary.c +++ b/src/data/dictionary.c @@ -135,6 +135,8 @@ dict_clone (const struct dictionary *s) for (i = 0; i < s->var_cnt; i++) { + const struct vardict_info *svdi; + struct vardict_info dvdi; struct variable *sv = s->var[i]; struct variable *dv = dict_clone_var_assert (d, sv, var_get_name (sv)); size_t i; @@ -142,7 +144,10 @@ dict_clone (const struct dictionary *s) for (i = 0; i < var_get_short_name_cnt (sv); i++) var_set_short_name (dv, i, var_get_short_name (sv, i)); - var_set_vardict (dv, var_get_vardict (sv)); + svdi = var_get_vardict (sv); + dvdi = *svdi; + dvdi.dict = d; + var_set_vardict (dv, &dvdi); } d->next_value_idx = s->next_value_idx; @@ -388,6 +393,12 @@ dict_lookup_var (const struct dictionary *d, const char *name) result = hsh_find (d->name_tab, target); var_destroy (target); + if ( result && var_has_vardict (result)) + { + const struct vardict_info *vdi = var_get_vardict (result); + assert (vdi->dict == d); + } + return result; } @@ -1161,9 +1172,7 @@ dict_var_changed (const struct variable *v) if ( var_has_vardict (v)) { const struct vardict_info *vdi = var_get_vardict (v); - struct dictionary *d; - - d = vdi->dict; + struct dictionary *d = vdi->dict; if ( d->callbacks && d->callbacks->var_changed ) d->callbacks->var_changed (d, var_get_dict_index (v), d->cb_data);