dictionary: Fix memory leak in dict_set_encoding().
[pspp] / src / data / dictionary.c
index f69d91e3605ed246302740c74e1cb2f47ef3d8f7..bca92dabe300b4c34439845c47abf485c900a778 100644 (file)
@@ -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 *