diff options
author | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2017-04-12 13:48:11 +0000 |
---|---|---|
committer | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2017-04-12 13:48:11 +0000 |
commit | 6e977b4f3e4a5aeb1ac024e254caec71ec4baf3f (patch) | |
tree | e2bf1a5a928b474d6fa90caa0c6dd64b368e0510 /src | |
parent | a4182afdd39d6d178390f0572f4131dfa2579316 (diff) | |
download | pcre2-6e977b4f3e4a5aeb1ac024e254caec71ec4baf3f.tar.gz |
Fix valgrind warnings for unset padding at the end of the pcre2_real_code
structure.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@743 6239d852-aaf2-0410-a92c-79f79f948069
Diffstat (limited to 'src')
-rw-r--r-- | src/pcre2_compile.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index e823747..0c46b52 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -9283,7 +9283,14 @@ if (re == NULL) errorcode = ERR21; goto HAD_CB_ERROR; } + +/* The compiler may put padding at the end of the pcre2_real_code structure in +order to round it up to a multiple of 4 or 8 bytes. This means that when a +compiled pattern is copied (for example, when serialized) undefined bytes are +read, and this annoys debuggers such as valgrind. To avoid this, we explicitly +write to the last 8 bytes of the structure before setting the fields. */ +memset((char *)re + sizeof(pcre2_real_code) - 8, 0, 8); re->memctl = ccontext->memctl; re->tables = tables; re->executable_jit = NULL; |