From f49ed94900625697d344071290cf2360293c27e3 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 23 Apr 2007 01:32:29 +0000 Subject: [PATCH] Patch #5885. (dict_set_split_vars): dict_destroy expects that dict_clear will free most data related to the dictionary. dict_clear does a decent job, except that dict_set_split_vars on some systems won't actually free the dict's "split" member. Instead, it'll allocate a 1-byte region. Fix this. --- src/data/ChangeLog | 6 ++++++ src/data/dictionary.c | 13 +++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/data/ChangeLog b/src/data/ChangeLog index 73177f5b..1a3e1f22 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,5 +1,11 @@ 2007-04-22 Ben Pfaff + * dictionary.c (dict_set_split_vars): dict_destroy expects that + dict_clear will free most data related to the dictionary. + dict_clear does a decent job, except that dict_set_split_vars on + some systems won't actually free the dict's "split" member. + Instead, it'll allocate a 1-byte region. Fix this. + * value.c (value_copy): New function. (value_set_missing): Ditto. diff --git a/src/data/dictionary.c b/src/data/dictionary.c index 761b540b..6857f62f 100644 --- a/src/data/dictionary.c +++ b/src/data/dictionary.c @@ -444,11 +444,12 @@ reindex_vars (struct dictionary *d, size_t from, size_t to) /* Deletes variable V from dictionary D and frees V. This is a very bad idea if there might be any pointers to V - from outside D. In general, no variable in should be deleted when - any transformations are active on the dictionary's dataset, because - those transformations might reference the deleted variable. - The safest time to delete a variable is just after a procedure - has been executed, as done by MODIFY VARS. + from outside D. In general, no variable in the active file's + dictionary should be deleted when any transformations are + active on the dictionary's dataset, because those + transformations might reference the deleted variable. The + safest time to delete a variable is just after a procedure has + been executed, as done by MODIFY VARS. Pointers to V within D are not a problem, because dict_delete_var() knows to remove V from split variables, @@ -1057,7 +1058,7 @@ dict_set_split_vars (struct dictionary *d, assert (cnt == 0 || split != NULL); d->split_cnt = cnt; - d->split = xnrealloc (d->split, cnt, sizeof *d->split); + d->split = cnt > 0 ? xnrealloc (d->split, cnt, sizeof *d->split) : NULL; memcpy (d->split, split, cnt * sizeof *d->split); if ( d->callbacks && d->callbacks->split_changed ) -- 2.30.2