summaryrefslogtreecommitdiff
path: root/pcretest.c
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-08-26 16:30:50 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-08-26 16:30:50 +0000
commitd3011fc1d300f091ee157a07123ab91296f5de56 (patch)
tree4abee3828789f53b8e700edb50604d3297e34feb /pcretest.c
parent583cb7af384d4ee223eb19b3838a3c5bc849b997 (diff)
downloadpcre-d3011fc1d300f091ee157a07123ab91296f5de56.tar.gz
Tidies to pcretest to ensure freeing memory and closing files.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1017 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcretest.c')
-rw-r--r--pcretest.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/pcretest.c b/pcretest.c
index 61245c6..f4bdef9 100644
--- a/pcretest.c
+++ b/pcretest.c
@@ -2652,6 +2652,13 @@ while (!done)
(sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7];
re = (pcre *)new_malloc(true_size);
+ if (re == NULL)
+ {
+ printf("** Failed to get %d bytes of memory for pcre object\n",
+ (int)true_size);
+ yield = 1;
+ goto EXIT;
+ }
regex_gotten_store = first_gotten_store;
if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ;
@@ -2666,6 +2673,7 @@ while (!done)
else
{
fprintf(outfile, "Data in %s is not a compiled PCRE regex\n", p);
+ new_free(re);
fclose(f);
continue;
}
@@ -2695,7 +2703,7 @@ while (!done)
{
PCRE_FREE_STUDY(extra);
}
- if (re != NULL) new_free(re);
+ new_free(re);
fclose(f);
continue;
}
@@ -2716,13 +2724,20 @@ while (!done)
use_pcre16? "16" : "", PCRE_INFO_OPTIONS);
fprintf(outfile, "Running in %s-bit mode but pattern was compiled in "
"%s-bit mode\n", use_pcre16? "16":"8", use_pcre16? "8":"16");
+ new_free(re);
+ fclose(f);
continue;
}
}
/* Need to know if UTF-8 for printing data strings. */
- if (new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options) < 0) continue;
+ if (new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options) < 0)
+ {
+ new_free(re);
+ fclose(f);
+ continue;
+ }
use_utf = (get_options & PCRE_UTF8) != 0;
fclose(f);
@@ -3979,12 +3994,9 @@ while (!done)
if (find_match_limit)
{
- if (extra == NULL)
- {
- extra = (pcre_extra *)malloc(sizeof(pcre_extra));
- extra->flags = 0;
- }
- else extra->flags &= ~PCRE_EXTRA_EXECUTABLE_JIT;
+ if (extra != NULL) { PCRE_FREE_STUDY(extra); }
+ extra = (pcre_extra *)malloc(sizeof(pcre_extra));
+ extra->flags = 0;
(void)check_match_limit(re, extra, bptr, len, start_offset,
options|g_notempty, use_offsets, use_size_offsets,
@@ -4465,6 +4477,11 @@ free(offsets);
if (buffer16 != NULL) free(buffer16);
#endif
+#if !defined NODFA
+if (dfa_workspace != NULL)
+ free(dfa_workspace);
+#endif
+
return yield;
}