summaryrefslogtreecommitdiff
path: root/rdoff
diff options
context:
space:
mode:
authorPhilipp Kloke <philipp.kloke@web.de>2013-03-31 12:02:30 +0200
committerCyrill Gorcunov <gorcunov@gmail.com>2013-04-01 02:16:27 +0400
commitdae212d049b1c6f737f14fe5c904adb6da432d8c (patch)
treecd721088e02362a5d5edb3f43828827aeb04bf0d /rdoff
parentb432f5774123e20a210c473a85c102333514d1f1 (diff)
downloadnasm-dae212d049b1c6f737f14fe5c904adb6da432d8c.tar.gz
nasm-dae212d049b1c6f737f14fe5c904adb6da432d8c.tar.bz2
nasm-dae212d049b1c6f737f14fe5c904adb6da432d8c.zip
Fixed several resource and memory leaks
Bug found by: CppCheck 1.59 (static source analysis tool) Signed-off-by: Philipp Kloke <philipp.kloke@web.de> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'rdoff')
-rw-r--r--rdoff/ldrdf.c2
-rw-r--r--rdoff/rdfload.c1
-rw-r--r--rdoff/rdlib.c3
3 files changed, 5 insertions, 1 deletions
diff --git a/rdoff/ldrdf.c b/rdoff/ldrdf.c
index 2ddada3..7c61d4c 100644
--- a/rdoff/ldrdf.c
+++ b/rdoff/ldrdf.c
@@ -1275,12 +1275,14 @@ int main(int argc, char **argv)
if ((p = strchr(buf, '\n')) != NULL)
*p = '\0';
if (i >= 128) {
+ fclose(f);
fprintf(stderr, "ldrdf: too many input files\n");
exit(1);
}
*(respstrings + i) = newstr(buf);
argc++, i++;
}
+ fclose(f);
break;
}
case '2':
diff --git a/rdoff/rdfload.c b/rdoff/rdfload.c
index 4fd3dbd..5a7ab63 100644
--- a/rdoff/rdfload.c
+++ b/rdoff/rdfload.c
@@ -94,6 +94,7 @@ rdfmodule *rdfload(const char *filename)
if (f->d)
free(f->d);
free(f);
+ free(hdr);
return NULL;
}
diff --git a/rdoff/rdlib.c b/rdoff/rdlib.c
index 31dbdb4..838f140 100644
--- a/rdoff/rdlib.c
+++ b/rdoff/rdlib.c
@@ -59,7 +59,7 @@ char *rdl_errors[5] = {
int rdl_verify(const char *filename)
{
- FILE *fp = fopen(filename, "rb");
+ FILE *fp;
char buf[257];
int i;
int32_t length;
@@ -69,6 +69,7 @@ int rdl_verify(const char *filename)
if (lastresult != -1 && !strcmp(filename, lastverified))
return lastresult;
+ fp = fopen(filename, "rb");
strcpy(lastverified, filename);
if (!fp)