gettext-0.19.8-its-segfault.patch 1.3 KB

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