summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/pcre2/src/pcre2_serialize.c
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-10-20 23:00:27 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2018-10-20 23:19:30 +0000
commit9ef793ba9539b4eddb7893c0df9be6e211d9984f (patch)
tree7b9374b8dcc8cbbc3b92636b2029f1b55c5e3194 /src/3rdparty/pcre2/src/pcre2_serialize.c
parente631e900fd0cd7467b1dccb5fa401afdcd1e41a8 (diff)
parent7a252ac46780b6145084d8d5ca0549b2de3639cc (diff)
Merge "Merge remote-tracking branch 'origin/5.11' into 5.12" into refs/staging/5.12
Diffstat (limited to 'src/3rdparty/pcre2/src/pcre2_serialize.c')
-rw-r--r--src/3rdparty/pcre2/src/pcre2_serialize.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/3rdparty/pcre2/src/pcre2_serialize.c b/src/3rdparty/pcre2/src/pcre2_serialize.c
index d2cc603cbb..cec1a035d1 100644
--- a/src/3rdparty/pcre2/src/pcre2_serialize.c
+++ b/src/3rdparty/pcre2/src/pcre2_serialize.c
@@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
- New API code Copyright (c) 2016-2017 University of Cambridge
+ New API code Copyright (c) 2016-2018 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -127,7 +127,25 @@ dst_bytes += tables_length;
for (i = 0; i < number_of_codes; i++)
{
re = (const pcre2_real_code *)(codes[i]);
- memcpy(dst_bytes, (char *)re, re->blocksize);
+ (void)memcpy(dst_bytes, (char *)re, re->blocksize);
+
+ /* Certain fields in the compiled code block are re-set during
+ deserialization. In order to ensure that the serialized data stream is always
+ the same for the same pattern, set them to zero here. We can't assume the
+ copy of the pattern is correctly aligned for accessing the fields as part of
+ a structure. Note the use of sizeof(void *) in the second of these, to
+ specify the size of a pointer. If sizeof(uint8_t *) is used (tables is a
+ pointer to uint8_t), gcc gives a warning because the first argument is also a
+ pointer to uint8_t. Casting the first argument to (void *) can stop this, but
+ it didn't stop Coverity giving the same complaint. */
+
+ (void)memset(dst_bytes + offsetof(pcre2_real_code, memctl), 0,
+ sizeof(pcre2_memctl));
+ (void)memset(dst_bytes + offsetof(pcre2_real_code, tables), 0,
+ sizeof(void *));
+ (void)memset(dst_bytes + offsetof(pcre2_real_code, executable_jit), 0,
+ sizeof(void *));
+
dst_bytes += re->blocksize;
}