summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2018-01-21 09:46:31 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2018-01-21 09:46:31 -0800
commit4c8552170ed8ac71b670c68e40b170f7f61d0a98 (patch)
treeb00e750aa657639a7e05a982a7dc819aa441d4bd
parent0ce5ff2a873e9da503ffa88f00082a92e181b9e3 (diff)
parent5c656716ff3932953efd2a225c8d60b609058cf6 (diff)
downloadzsh-4c8552170ed8ac71b670c68e40b170f7f61d0a98.tar.gz
zsh-4c8552170ed8ac71b670c68e40b170f7f61d0a98.tar.xz
zsh-4c8552170ed8ac71b670c68e40b170f7f61d0a98.zip
Fix overlapping commits
-rw-r--r--ChangeLog5
-rw-r--r--Src/Modules/pcre.c35
2 files changed, 39 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 7fd0e5409..3c1192b3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-20  Mikael Magnusson  <mikachu@gmail.com>
+
+	* 42243: Src/Modules/pcre.c: Free stuff properly in zsh/pcre
+	module
+
 2018-01-19  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* dana: 41924: Doc/Zsh/params.yo: (wi) subscript flag interaction
diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c
index 659fd22d5..15ee34bc8 100644
--- a/Src/Modules/pcre.c
+++ b/Src/Modules/pcre.c
@@ -88,10 +88,19 @@ bin_pcre_compile(char *nam, char **args, Options ops, UNUSED(int func))
     if (zpcre_utf8_enabled())
 	pcre_opts |= PCRE_UTF8;
 
-    pcre_hints = NULL;  /* Is this necessary? */
+#ifdef HAVE_PCRE_STUDY
+    if (pcre_hints)
+#ifdef PCRE_CONFIG_JIT
+	pcre_free_study(pcre_hints);
+#else
+	pcre_free(pcre_hints);
+#endif
+    pcre_hints = NULL;
+#endif
 
     if (pcre_pattern)
 	pcre_free(pcre_pattern);
+    pcre_pattern = NULL;
 
     target = ztrdup(*args);
     unmetafy(target, &target_len);
@@ -128,6 +137,14 @@ bin_pcre_study(char *nam, UNUSED(char **args), UNUSED(Options ops), UNUSED(int f
 	return 1;
     }
     
+    if (pcre_hints)
+#ifdef PCRE_CONFIG_JIT
+	pcre_free_study(pcre_hints);
+#else
+	pcre_free(pcre_hints);
+#endif
+    pcre_hints = NULL;
+
     pcre_hints = pcre_study(pcre_pattern, 0, &pcre_error);
     if (pcre_error != NULL)
     {
@@ -528,5 +545,21 @@ cleanup_(Module m)
 int
 finish_(UNUSED(Module m))
 {
+#if defined(HAVE_PCRE_COMPILE) && defined(HAVE_PCRE_EXEC)
+#ifdef HAVE_PCRE_STUDY
+    if (pcre_hints)
+#ifdef PCRE_CONFIG_JIT
+	pcre_free_study(pcre_hints);
+#else
+	pcre_free(pcre_hints);
+#endif
+    pcre_hints = NULL;
+#endif
+
+    if (pcre_pattern)
+	pcre_free(pcre_pattern);
+    pcre_pattern = NULL;
+#endif
+
     return 0;
 }