Fix memory leak in pcre2test (found by Coverity Scan).
This commit is contained in:
parent
ba1c759c90
commit
587011e326
|
@ -5310,6 +5310,7 @@ it ends up back in the usual place. */
|
||||||
if (pat_patctl.convert_type != CONVERT_UNSET)
|
if (pat_patctl.convert_type != CONVERT_UNSET)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
int convert_return = PR_OK;
|
||||||
uint32_t convert_options = pat_patctl.convert_type;
|
uint32_t convert_options = pat_patctl.convert_type;
|
||||||
void *converted_pattern;
|
void *converted_pattern;
|
||||||
PCRE2_SIZE converted_length;
|
PCRE2_SIZE converted_length;
|
||||||
|
@ -5338,32 +5339,42 @@ if (pat_patctl.convert_type != CONVERT_UNSET)
|
||||||
{
|
{
|
||||||
fprintf(outfile, "** Invalid glob separator '%c'\n",
|
fprintf(outfile, "** Invalid glob separator '%c'\n",
|
||||||
pat_patctl.convert_glob_separator);
|
pat_patctl.convert_glob_separator);
|
||||||
return PR_SKIP;
|
convert_return = PR_SKIP;
|
||||||
|
goto CONVERT_FINISH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PCRE2_PATTERN_CONVERT(rc, pbuffer, patlen, convert_options,
|
PCRE2_PATTERN_CONVERT(rc, pbuffer, patlen, convert_options,
|
||||||
&converted_pattern, &converted_length, con_context);
|
&converted_pattern, &converted_length, con_context);
|
||||||
|
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
{
|
{
|
||||||
fprintf(outfile, "** Pattern conversion error at offset %lu: ",
|
fprintf(outfile, "** Pattern conversion error at offset %lu: ",
|
||||||
converted_length);
|
converted_length);
|
||||||
if (!print_error_message(rc, "", "\n")) return PR_ABEND;
|
convert_return = print_error_message(rc, "", "\n")? PR_SKIP:PR_ABEND;
|
||||||
return PR_SKIP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output the converted pattern, copy it, then free it. */
|
/* Output the converted pattern, then copy it. */
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
PCHARSV(converted_pattern, 0, converted_length, utf, outfile);
|
PCHARSV(converted_pattern, 0, converted_length, utf, outfile);
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
|
|
||||||
patlen = converted_length;
|
patlen = converted_length;
|
||||||
CONVERT_COPY(pbuffer, converted_pattern, converted_length + 1);
|
CONVERT_COPY(pbuffer, converted_pattern, converted_length + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free the converted pattern. */
|
||||||
|
|
||||||
|
CONVERT_FINISH:
|
||||||
if (pat_patctl.convert_length != 0)
|
if (pat_patctl.convert_length != 0)
|
||||||
free(converted_pattern);
|
free(converted_pattern);
|
||||||
else
|
else
|
||||||
PCRE2_CONVERTED_PATTERN_FREE(converted_pattern);
|
PCRE2_CONVERTED_PATTERN_FREE(converted_pattern);
|
||||||
|
|
||||||
|
/* Return if conversion was unsuccessful. */
|
||||||
|
|
||||||
|
if (convert_return != PR_OK) return convert_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* By default we pass a zero-terminated pattern, but a length is passed if
|
/* By default we pass a zero-terminated pattern, but a length is passed if
|
||||||
|
|
Loading…
Reference in New Issue