summaryrefslogtreecommitdiff
path: root/Src/Modules/pcre.c
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2018-04-07 15:12:57 +0200
committerAxel Beckert <abe@deuxchevaux.org>2018-04-07 15:12:57 +0200
commit6e1ab9aa550695ee7e3d467b4173c0b83ba7f759 (patch)
tree8fb7faa4364a7cbf1cba48296a5f537e13f2a8d9 /Src/Modules/pcre.c
parent5ad56a41f1ee2e61abca079f5ea8909f895ac2dd (diff)
parentf027f1d6e876708bc75d4217e1ca26898658d8d3 (diff)
downloadzsh-6e1ab9aa550695ee7e3d467b4173c0b83ba7f759.tar.gz
zsh-6e1ab9aa550695ee7e3d467b4173c0b83ba7f759.zip
Merge tag 'zsh-5.4.2-test-2' / 'upstream' branch into 'debian' branch
Test version 2 prior to zsh 5.5.
Diffstat (limited to 'Src/Modules/pcre.c')
-rw-r--r--Src/Modules/pcre.c35
1 files changed, 34 insertions, 1 deletions
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;
}