930b2f
From a0cab23332a254e3500cac2a3a984472d02180e5 Mon Sep 17 00:00:00 2001
930b2f
From: Bruno Haible <bruno@clisp.org>
930b2f
Date: Fri, 9 Dec 2016 21:04:31 +0100
930b2f
Subject: [PATCH] Fix crash of xgettext with --its option.
930b2f
930b2f
* gettext-tools/src/xgettext.c (main): Free contents of its_dirs only when it
930b2f
was initialized. Fixes bug introduced on 2016-05-16.
930b2f
---
930b2f
 gettext-tools/src/xgettext.c | 11 +++++++----
930b2f
 1 file changed, 7 insertions(+), 4 deletions(-)
930b2f
930b2f
diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c
930b2f
index f848d76d1..a80ee51ac 100644
930b2f
--- a/gettext-tools/src/xgettext.c
930b2f
+++ b/gettext-tools/src/xgettext.c
930b2f
@@ -330,7 +330,7 @@ main (int argc, char *argv[])
930b2f
   bool sort_by_msgid = false;
930b2f
   bool sort_by_filepos = false;
930b2f
   char **dirs;
930b2f
-  char **its_dirs;
930b2f
+  char **its_dirs = NULL;
930b2f
   char *explicit_its_filename = NULL;
930b2f
   const char *file_name;
930b2f
   const char *files_from = NULL;
930b2f
@@ -1016,9 +1016,12 @@ warning: file '%s' extension '%s' is unknown; will try C"), filename, extension)
930b2f
   if (its_locating_rules)
930b2f
     locating_rule_list_free (its_locating_rules);
930b2f
 
930b2f
-  for (i = 0; its_dirs[i] != NULL; i++)
930b2f
-    free (its_dirs[i]);
930b2f
-  free (its_dirs);
930b2f
+  if (its_dirs != NULL)
930b2f
+    {
930b2f
+      for (i = 0; its_dirs[i] != NULL; i++)
930b2f
+        free (its_dirs[i]);
930b2f
+      free (its_dirs);
930b2f
+    }
930b2f
 
930b2f
   exit (EXIT_SUCCESS);
930b2f
 }
930b2f
-- 
930b2f
2.14.3
930b2f