From 01900114dde51eecc8adc4933ef52289e37c480f Mon Sep 17 00:00:00 2001
From: Ben Pfaff <blp@cs.stanford.edu>
Date: Thu, 8 Apr 2010 21:12:02 -0700
Subject: [PATCH] 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.
---
 src/data/dictionary.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/data/dictionary.c b/src/data/dictionary.c
index f69d91e360..bca92dabe3 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 *
-- 
2.30.2