Tidies and minor bug fix resulting from Coverity Scan issues.
This commit is contained in:
parent
e21268b367
commit
41d1c6d6ce
|
@ -140,6 +140,15 @@ particular when it is serialized.
|
|||
27. Update pcre2test, remove some unused code in pcre2_match(), and upgrade the
|
||||
tests to improve coverage.
|
||||
|
||||
28. Some fixes/tidies as a result of looking at Coverity Scan output:
|
||||
|
||||
(a) Typo: ">" should be ">=" in opcode check in pcre2_auto_possess.c.
|
||||
(b) Added some casts to avoid "suspicious implicit sign extension".
|
||||
(c) Resource leaks in pcre2test in rare error cases.
|
||||
(d) Avoid warning for never-use case OP_TABLE_LENGTH which is just a fudge
|
||||
for checking at compile time that tables are the right size.
|
||||
(e) Add missing "fall through" comment.
|
||||
|
||||
|
||||
Version 10.23 14-February-2017
|
||||
------------------------------
|
||||
|
|
|
@ -1075,7 +1075,7 @@ for (;;)
|
|||
{
|
||||
c = *code;
|
||||
|
||||
if (c > OP_TABLE_LENGTH) return -1; /* Something gone wrong */
|
||||
if (c >= OP_TABLE_LENGTH) return -1; /* Something gone wrong */
|
||||
|
||||
if (c >= OP_STAR && c <= OP_TYPEPOSUPTO)
|
||||
{
|
||||
|
|
|
@ -8440,6 +8440,7 @@ for (;; pptr++)
|
|||
case META_BACKREF_BYNAME:
|
||||
if ((cb->external_options & PCRE2_MATCH_UNSET_BACKREF) != 0)
|
||||
goto ISNOTFIXED;
|
||||
/* Fall through */
|
||||
|
||||
case META_RECURSE_BYNAME:
|
||||
{
|
||||
|
@ -9274,7 +9275,8 @@ possible because nowadays we limit the maximum value of cb.names_found and
|
|||
cb.name_entry_size. */
|
||||
|
||||
re_blocksize = sizeof(pcre2_real_code) +
|
||||
CU2BYTES(length + cb.names_found * cb.name_entry_size);
|
||||
CU2BYTES(length +
|
||||
(PCRE2_SIZE)cb.names_found * (PCRE2_SIZE)cb.name_entry_size);
|
||||
re = (pcre2_real_code *)
|
||||
ccontext->memctl.malloc(re_blocksize, ccontext->memctl.memory_data);
|
||||
if (re == NULL)
|
||||
|
|
|
@ -697,7 +697,7 @@ for (;;)
|
|||
case OP_TABLE_LENGTH +
|
||||
((sizeof(coptable) == OP_TABLE_LENGTH) &&
|
||||
(sizeof(poptable) == OP_TABLE_LENGTH)):
|
||||
break;
|
||||
return 0;
|
||||
|
||||
/* ========================================================================== */
|
||||
/* Reached a closing bracket. If not at the end of the pattern, carry
|
||||
|
|
|
@ -340,7 +340,7 @@ for(;;)
|
|||
case OP_TABLE_LENGTH +
|
||||
((sizeof(OP_names)/sizeof(const char *) == OP_TABLE_LENGTH) &&
|
||||
(sizeof(OP_lengths) == OP_TABLE_LENGTH)):
|
||||
break;
|
||||
return;
|
||||
/* ========================================================================== */
|
||||
|
||||
case OP_END:
|
||||
|
|
|
@ -4434,7 +4434,7 @@ process_command(void)
|
|||
FILE *f;
|
||||
PCRE2_SIZE serial_size;
|
||||
size_t i;
|
||||
int rc, cmd, cmdlen;
|
||||
int rc, cmd, cmdlen, yield;
|
||||
uint16_t first_listed_newline;
|
||||
const char *cmdname;
|
||||
uint8_t *argptr, *serial;
|
||||
|
@ -4445,6 +4445,7 @@ if (restrict_for_perl_test)
|
|||
return PR_ABEND;
|
||||
}
|
||||
|
||||
yield = PR_OK;
|
||||
cmd = CMD_UNKNOWN;
|
||||
cmdlen = 0;
|
||||
|
||||
|
@ -4568,8 +4569,8 @@ switch(cmd)
|
|||
general_context);
|
||||
if (rc < 0)
|
||||
{
|
||||
if (!serial_error(rc, "Serialization")) return PR_ABEND;
|
||||
fclose(f);
|
||||
if (!serial_error(rc, "Serialization")) return PR_ABEND;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4615,44 +4616,46 @@ switch(cmd)
|
|||
return PR_ABEND;
|
||||
}
|
||||
|
||||
if (fread(serial, 1, serial_size, f) != serial_size)
|
||||
{
|
||||
fprintf(outfile, "** Wrong return from fread()\n");
|
||||
free(serial);
|
||||
fclose(f);
|
||||
return PR_ABEND;
|
||||
}
|
||||
i = fread(serial, 1, serial_size, f);
|
||||
fclose(f);
|
||||
|
||||
PCRE2_SERIALIZE_GET_NUMBER_OF_CODES(rc, serial);
|
||||
if (rc < 0)
|
||||
if (i != serial_size)
|
||||
{
|
||||
if (!serial_error(rc, "Get number of codes")) return PR_ABEND;
|
||||
fprintf(outfile, "** Wrong return from fread()\n");
|
||||
yield = PR_ABEND;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rc + patstacknext > PATSTACKSIZE)
|
||||
{
|
||||
fprintf(outfile, "** Not enough space on pattern stack for %d pattern%s\n",
|
||||
rc, (rc == 1)? "" : "s");
|
||||
rc = PATSTACKSIZE - patstacknext;
|
||||
fprintf(outfile, "** Decoding %d pattern%s\n", rc,
|
||||
(rc == 1)? "" : "s");
|
||||
}
|
||||
PCRE2_SERIALIZE_DECODE(rc, patstack + patstacknext, rc, serial,
|
||||
general_context);
|
||||
PCRE2_SERIALIZE_GET_NUMBER_OF_CODES(rc, serial);
|
||||
if (rc < 0)
|
||||
{
|
||||
if (!serial_error(rc, "Deserialization")) return PR_ABEND;
|
||||
if (!serial_error(rc, "Get number of codes")) yield = PR_ABEND;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rc + patstacknext > PATSTACKSIZE)
|
||||
{
|
||||
fprintf(outfile, "** Not enough space on pattern stack for %d pattern%s\n",
|
||||
rc, (rc == 1)? "" : "s");
|
||||
rc = PATSTACKSIZE - patstacknext;
|
||||
fprintf(outfile, "** Decoding %d pattern%s\n", rc,
|
||||
(rc == 1)? "" : "s");
|
||||
}
|
||||
PCRE2_SERIALIZE_DECODE(rc, patstack + patstacknext, rc, serial,
|
||||
general_context);
|
||||
if (rc < 0)
|
||||
{
|
||||
if (!serial_error(rc, "Deserialization")) yield = PR_ABEND;
|
||||
}
|
||||
else patstacknext += rc;
|
||||
}
|
||||
else patstacknext += rc;
|
||||
}
|
||||
|
||||
free(serial);
|
||||
break;
|
||||
}
|
||||
|
||||
return PR_OK;
|
||||
return yield;
|
||||
}
|
||||
|
||||
|
||||
|
@ -5429,7 +5432,7 @@ for (;;)
|
|||
else
|
||||
PCRE2_MATCH(capcount, compiled_code, pp, ulen, dat_datctl.offset,
|
||||
dat_datctl.options, match_data, PTR(dat_context));
|
||||
|
||||
|
||||
if (capcount == errnumber)
|
||||
{
|
||||
min = mid;
|
||||
|
@ -7896,7 +7899,7 @@ functions that are not otherwise called. */
|
|||
if (test_mode == PCRE8_MODE)
|
||||
{
|
||||
CREATECONTEXTS;
|
||||
CONTEXTTESTS;
|
||||
CONTEXTTESTS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -7906,7 +7909,7 @@ if (test_mode == PCRE8_MODE)
|
|||
if (test_mode == PCRE16_MODE)
|
||||
{
|
||||
CREATECONTEXTS;
|
||||
CONTEXTTESTS;
|
||||
CONTEXTTESTS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -7916,7 +7919,7 @@ if (test_mode == PCRE16_MODE)
|
|||
if (test_mode == PCRE32_MODE)
|
||||
{
|
||||
CREATECONTEXTS;
|
||||
CONTEXTTESTS;
|
||||
CONTEXTTESTS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue