代码同步

Signed-off-by: wu-liushuan <wuliushuan.30044128@h-partners.com>
Change-Id: Idcdc4080d1432dc0dc17b857957871b160e49c54
This commit is contained in:
wu-liushuan
2026-03-10 09:58:53 +08:00
parent 0dbf7695f7
commit 5c0cd4e120
+24 -13
View File
@@ -168,9 +168,10 @@ const pcre2_memctl *memctl = (gcontext != NULL) ?
&gcontext->memctl : &PRIV(default_compile_context).memctl;
const uint8_t *src_bytes;
pcre2_real_code *dst_re;
pcre2_real_code *dst_re = NULL;
uint8_t *tables;
int32_t i, j;
int32_t error;
/* Sanity checks. */
@@ -208,7 +209,10 @@ for (i = 0; i < number_of_codes; i++)
memcpy(&blocksize, src_bytes + offsetof(pcre2_real_code, blocksize),
sizeof(CODE_BLOCKSIZE_TYPE));
if (blocksize <= sizeof(pcre2_real_code))
return PCRE2_ERROR_BADSERIALIZEDDATA;
{
error = PCRE2_ERROR_BADSERIALIZEDDATA;
goto cleanup;
}
/* The allocator provided by gcontext replaces the original one. */
@@ -216,13 +220,8 @@ for (i = 0; i < number_of_codes; i++)
(pcre2_memctl *)gcontext);
if (dst_re == NULL)
{
memctl->free(tables, memctl->memory_data);
for (j = 0; j < i; j++)
{
memctl->free(codes[j], memctl->memory_data);
codes[j] = NULL;
}
return PCRE2_ERROR_NOMEMORY;
error = PCRE2_ERROR_NOMEMORY;
goto cleanup;
}
/* The new allocator must be preserved. */
@@ -232,10 +231,10 @@ for (i = 0; i < number_of_codes; i++)
if (dst_re->magic_number != MAGIC_NUMBER ||
dst_re->name_entry_size > MAX_NAME_SIZE + IMM2_SIZE + 1 ||
dst_re->name_count > MAX_NAME_COUNT)
{
memctl->free(dst_re, memctl->memory_data);
return PCRE2_ERROR_BADSERIALIZEDDATA;
}
{
error = PCRE2_ERROR_BADSERIALIZEDDATA;
goto cleanup;
}
/* At the moment only one table is supported. */
@@ -244,10 +243,22 @@ for (i = 0; i < number_of_codes; i++)
dst_re->flags |= PCRE2_DEREF_TABLES;
codes[i] = dst_re;
dst_re = NULL;
src_bytes += blocksize;
}
return number_of_codes;
cleanup:
if (dst_re != NULL)
memctl->free(dst_re, memctl->memory_data);
memctl->free(tables, memctl->memory_data);
for (j = 0; j < i; j++)
{
memctl->free(codes[j], memctl->memory_data);
codes[j] = NULL;
}
return error;
}