From: Ben Pfaff Date: Fri, 9 Apr 2010 04:12:02 +0000 (-0700) Subject: dictionary: Fix memory leak in dict_set_encoding(). X-Git-Tag: v0.7.5~84 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01900114dde51eecc8adc4933ef52289e37c480f;p=pspp-builds.git dictionary: Fix memory leak in dict_set_encoding(). If this function was called more than once for a given dictionary then all but the final encoding name would be leaked. --- diff --git a/src/data/dictionary.c b/src/data/dictionary.c index f69d91e3..bca92dab 100644 --- a/src/data/dictionary.c +++ b/src/data/dictionary.c @@ -81,7 +81,10 @@ void dict_set_encoding (struct dictionary *d, const char *enc) { if (enc) - d->encoding = xstrdup (enc); + { + free (d->encoding); + d->encoding = xstrdup (enc); + } } const char *