Close serialization file in pcre2test after any error.

This commit is contained in:
Philip.Hazel 2017-03-21 16:18:54 +00:00
parent ca75518017
commit 8e4eb8dbc8
2 changed files with 7 additions and 0 deletions

View File

@ -68,6 +68,9 @@ empty string with zero_terminate. This was a bug in pcre2test, not the library.
of the section that is compiled when Unix-style directory scanning is of the section that is compiled when Unix-style directory scanning is
available, and into a new section that is always compiled for Windows. available, and into a new section that is always compiled for Windows.
10. In pcre2test, explicitly close the file after an error during serialization
or deserialization (the "load" or "save" commands).
Version 10.23 14-February-2017 Version 10.23 14-February-2017
------------------------------ ------------------------------

View File

@ -4456,6 +4456,7 @@ switch(cmd)
if (rc < 0) if (rc < 0)
{ {
serial_error(rc, "Serialization"); serial_error(rc, "Serialization");
fclose(f);
break; break;
} }
@ -4469,6 +4470,7 @@ switch(cmd)
if (fwrite(serial, 1, serial_size, f) != serial_size) if (fwrite(serial, 1, serial_size, f) != serial_size)
{ {
fprintf(outfile, "** Wrong return from fwrite()\n"); fprintf(outfile, "** Wrong return from fwrite()\n");
fclose(f);
return PR_ABEND; return PR_ABEND;
} }
@ -4496,6 +4498,7 @@ switch(cmd)
{ {
fprintf(outfile, "** Failed to get memory (size %lu) for #load\n", fprintf(outfile, "** Failed to get memory (size %lu) for #load\n",
(unsigned long int)serial_size); (unsigned long int)serial_size);
fclose(f);
return PR_ABEND; return PR_ABEND;
} }
@ -4503,6 +4506,7 @@ switch(cmd)
{ {
fprintf(outfile, "** Wrong return from fread()\n"); fprintf(outfile, "** Wrong return from fread()\n");
free(serial); free(serial);
fclose(f);
return PR_ABEND; return PR_ABEND;
} }
fclose(f); fclose(f);