diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-04-06 16:20:30 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2022-04-06 16:25:25 -0400 |
commit | 8e8a1021c3cacd5c4736a93ffb53a1143d5077c4 (patch) | |
tree | 049575b6314091b1464377da212747d1c306a8cb | |
parent | 209fd61b32855aa3151e222dee1513ec1fa362d3 (diff) | |
download | haskell-8e8a1021c3cacd5c4736a93ffb53a1143d5077c4.tar.gz |
rts/linker/LoadArchive: Fix leaking file handlewip/windows-high-linker
Previously `isArchive` could leak a `FILE` handle if the `fread`
returned a short read.
-rw-r--r-- | rts/linker/LoadArchive.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/rts/linker/LoadArchive.c b/rts/linker/LoadArchive.c index 265afd319c..a2641e83ad 100644 --- a/rts/linker/LoadArchive.c +++ b/rts/linker/LoadArchive.c @@ -645,10 +645,10 @@ bool isArchive (pathchar *path) } size_t ret = fread(buffer, 1, sizeof(buffer), f); + fclose(f); if (ret < sizeof(buffer)) { return false; } - fclose(f); return strncmp(ARCHIVE_HEADER, buffer, sizeof(ARCHIVE_HEADER)-1) == 0; } |