Fix resource leak in pcre2test introduced by recent patch.

This commit is contained in:
Philip.Hazel 2020-03-24 17:25:58 +00:00
parent 8057c3c8b9
commit f988433788
1 changed files with 7 additions and 6 deletions

View File

@ -5083,18 +5083,19 @@ switch(cmd)
{ {
(void)PCRE2_CONFIG(PCRE2_CONFIG_TABLES_LENGTH, &loadtables_length); (void)PCRE2_CONFIG(PCRE2_CONFIG_TABLES_LENGTH, &loadtables_length);
tables3 = malloc(loadtables_length); tables3 = malloc(loadtables_length);
if (tables3 == NULL)
{
fprintf(outfile, "** Failed: malloc failed for #loadtables\n");
return PR_ABEND;
}
} }
if (fread(tables3, 1, loadtables_length, f) != loadtables_length) if (tables3 == NULL)
{
fprintf(outfile, "** Failed: malloc failed for #loadtables\n");
yield = PR_ABEND;
}
else if (fread(tables3, 1, loadtables_length, f) != loadtables_length)
{ {
fprintf(outfile, "** Wrong return from fread()\n"); fprintf(outfile, "** Wrong return from fread()\n");
yield = PR_ABEND; yield = PR_ABEND;
} }
fclose(f); fclose(f);
break; break;
} }