summaryrefslogtreecommitdiff
path: root/pcre_study.c
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2011-12-06 15:37:24 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2011-12-06 15:37:24 +0000
commit475e97e3c2ef83094b3b2239b7cf4ffcc2c05f68 (patch)
treee29e71d1cf791f5a6bb5ad746bde31fb71bf8903 /pcre_study.c
parentfe230b59c018dd441d38ccc8eff23f35fd009a03 (diff)
downloadpcre-475e97e3c2ef83094b3b2239b7cf4ffcc2c05f68.tar.gz
Fix uninitialized memory use when writing study data to file if no starting
byte set exists. git-svn-id: svn://vcs.exim.org/pcre/code/trunk@787 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre_study.c')
-rw-r--r--pcre_study.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/pcre_study.c b/pcre_study.c
index 9da92bf..20e064a 100644
--- a/pcre_study.c
+++ b/pcre_study.c
@@ -286,8 +286,8 @@ for (;;)
cc++;
break;
- /* The single-byte matcher means we can't proceed in UTF-8 mode. (In
- non-UTF-8 mode \C will actually be turned into OP_ALLANY, so won't ever
+ /* The single-byte matcher means we can't proceed in UTF-8 mode. (In
+ non-UTF-8 mode \C will actually be turned into OP_ALLANY, so won't ever
appear, but leave the code, just in case.) */
case OP_ANYBYTE:
@@ -1321,12 +1321,17 @@ if (bits_set || min > 0
study->size = sizeof(pcre_study_data);
study->flags = 0;
+
+ /* Set the start bits always, to avoid unset memory errors if the
+ study data is written to a file, but set the flag only if any of the bits
+ are set, to save time looking when none are. */
- if (bits_set)
+ if (bits_set)
{
study->flags |= PCRE_STUDY_MAPPED;
memcpy(study->start_bits, start_bits, sizeof(start_bits));
}
+ else memset(study->start_bits, 0, 32 * sizeof(uschar));
/* Always set the minlength value in the block, because the JIT compiler
makes use of it. However, don't set the bit unless the length is greater than