diff --git a/ChangeLog b/ChangeLog index c07e631..4a9f6c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 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 ------------------------------ diff --git a/src/pcre2test.c b/src/pcre2test.c index 39eedbe..b6d3ec9 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -4456,6 +4456,7 @@ switch(cmd) if (rc < 0) { serial_error(rc, "Serialization"); + fclose(f); break; } @@ -4469,6 +4470,7 @@ switch(cmd) if (fwrite(serial, 1, serial_size, f) != serial_size) { fprintf(outfile, "** Wrong return from fwrite()\n"); + fclose(f); return PR_ABEND; } @@ -4496,6 +4498,7 @@ switch(cmd) { fprintf(outfile, "** Failed to get memory (size %lu) for #load\n", (unsigned long int)serial_size); + fclose(f); return PR_ABEND; } @@ -4503,6 +4506,7 @@ switch(cmd) { fprintf(outfile, "** Wrong return from fread()\n"); free(serial); + fclose(f); return PR_ABEND; } fclose(f);