ref: ac03b95b184b70f3fafc8f285bc2c4a796698035
parent: 1cbf19e7a950b965a8310ce09baae87c7f622ee8
author: Tor Andersson <tor.andersson@artifex.com>
date: Tue Aug 23 07:16:42 EDT 2022
Bug 705775: Fix double fclose in pretty-printing tool.
--- a/pp.c
+++ b/pp.c
@@ -44,24 +44,20 @@
}
if (fseek(f, 0, SEEK_END) < 0) {
- fclose(f);
js_error(J, "cannot seek in file: '%s'", filename);
}
n = ftell(f);
if (n < 0) {
- fclose(f);
js_error(J, "cannot tell in file: '%s'", filename);
}
if (fseek(f, 0, SEEK_SET) < 0) {
- fclose(f);
js_error(J, "cannot seek in file: '%s'", filename);
}
s = js_malloc(J, n + 1); /* add space for string terminator */
if (!s) {
- fclose(f);
js_error(J, "cannot allocate storage for file contents: '%s'", filename);
}
@@ -68,7 +64,6 @@
t = fread(s, 1, (size_t)n, f);
if (t != n) {
js_free(J, s);
- fclose(f);
js_error(J, "cannot read data from file: '%s'", filename);
}