Code

diff.c: call regfree to free memory allocated by regcomp when necessary
authorBrandon Casey <drafnel@gmail.com>
Thu, 9 Sep 2010 19:02:45 +0000 (14:02 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Sep 2010 00:18:04 +0000 (17:18 -0700)
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c

diff --git a/diff.c b/diff.c
index 93004922dee5b4f148dc8e6be5be469f1ffe75e6..19b5bf63ed37aa49c00e63f7aec621ce601b6daa 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -912,7 +912,10 @@ static void free_diff_words_data(struct emit_callback *ecbdata)
                free (ecbdata->diff_words->minus.orig);
                free (ecbdata->diff_words->plus.text.ptr);
                free (ecbdata->diff_words->plus.orig);
-               free(ecbdata->diff_words->word_regex);
+               if (ecbdata->diff_words->word_regex) {
+                       regfree(ecbdata->diff_words->word_regex);
+                       free(ecbdata->diff_words->word_regex);
+               }
                free(ecbdata->diff_words);
                ecbdata->diff_words = NULL;
        }