Skip to content

Commit

Permalink
Build warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NWilson committed Nov 29, 2024
1 parent 6c5b9f6 commit 3c7a67e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
19 changes: 13 additions & 6 deletions src/pcre2_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -6259,10 +6259,13 @@ for (;; pptr++)

else
{
BOOL need_map;
PCRE2_SIZE required_len;

PCRE2_ASSERT(op_info.op_single_type == ECL_XCLASS);
BOOL need_map = !allbitszero;
PCRE2_SIZE required_len = op_info.length +
(need_map? 32/sizeof(PCRE2_UCHAR) : 0);
need_map = !allbitszero;
required_len =
op_info.length + (need_map? 32/sizeof(PCRE2_UCHAR) : 0);

if (lengthptr != NULL)
{
Expand All @@ -6273,13 +6276,17 @@ for (;; pptr++)
}
else
{
PCRE2_UCHAR *rest;
PCRE2_SIZE rest_len;
PCRE2_UCHAR flags;

/* 1 unit: OP_XCLASS | LINK_SIZE units | 1 unit: flags | ...rest */
PCRE2_ASSERT(op_info.length >= 1 + LINK_SIZE + 1);
PCRE2_UCHAR *rest = op_info.code_start + 1 + LINK_SIZE + 1;
PCRE2_SIZE rest_len = (op_info.code_start + op_info.length) - rest;
rest = op_info.code_start + 1 + LINK_SIZE + 1;
rest_len = (op_info.code_start + op_info.length) - rest;

/* First read any data we use, before memmove splats it. */
PCRE2_UCHAR flags = op_info.code_start[1 + LINK_SIZE];
flags = op_info.code_start[1 + LINK_SIZE];
PCRE2_ASSERT((flags & XCL_MAP) == 0);

/* Next do the memmove before any writes. */
Expand Down
4 changes: 2 additions & 2 deletions src/pcre2_compile_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -2141,8 +2141,8 @@ switch (meta)

if ((flags & XCL_MAP) != 0)
{
PCRE2_ASSERT(
code - code_start >= 1 + LINK_SIZE + 1 + 32 / sizeof(PCRE2_UCHAR));
PCRE2_ASSERT(code - code_start >=
1 + LINK_SIZE + 1 + 32 / (int)sizeof(PCRE2_UCHAR));

put_length = GET(code_start, 1) - 32 / sizeof(PCRE2_UCHAR);
PUT(code_start, 1, (int)put_length);
Expand Down
2 changes: 1 addition & 1 deletion src/pcre2_xclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ int stack_depth = 0;
PCRE2_ASSERT(data_start < data_end);
flags = *ptr++;
PCRE2_ASSERT((flags & ECL_MAP) == 0 ||
(data_end - ptr) >= 32 / sizeof(PCRE2_UCHAR));
(data_end - ptr) >= 32 / (int)sizeof(PCRE2_UCHAR));

/* Code points < 256 are matched against a bitmap, if one is present. If no
bitmap is present, then the ECLASS does not match any code points < 256. */
Expand Down

0 comments on commit 3c7a67e

Please sign in to comment.