summaryrefslogtreecommitdiff
path: root/src/strgen/strgen.cpp
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2018-10-14 23:36:14 +0100
committerfrosch <github@elsenhans.name>2018-10-31 12:41:49 +0100
commitb5028efc1fa862073c908c435f84098ccd246fdc (patch)
treeec0a38f99b8885e4d977bb4e5ece8fd37d96a8e3 /src/strgen/strgen.cpp
parent52ed3bcbaa88717ab50f71150ed9fc0b6af4715a (diff)
downloadopenttd-b5028efc1fa862073c908c435f84098ccd246fdc.tar.xz
Fix: Protect against a few out of bounds or uninitialised usage errors
Diffstat (limited to 'src/strgen/strgen.cpp')
-rw-r--r--src/strgen/strgen.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index fa2942465..c231717da 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -215,7 +215,10 @@ bool CompareFiles(const char *n1, const char *n2)
if (f2 == NULL) return false;
FILE *f1 = fopen(n1, "rb");
- if (f1 == NULL) error("can't open %s", n1);
+ if (f1 == NULL) {
+ fclose(f2);
+ error("can't open %s", n1);
+ }
size_t l1, l2;
do {