0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-07-24 10:25:42 -04:00

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>
This commit is contained in:
Philipp Kloke 2013-03-31 12:02:30 +02:00 committed by Cyrill Gorcunov
parent b432f57741
commit dae212d049
4 changed files with 6 additions and 1 deletions

View File

@ -424,6 +424,7 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, uint32_t cp,
} else if (fseek(fp, 0L, SEEK_END) < 0) { } else if (fseek(fp, 0L, SEEK_END) < 0) {
error(ERR_NONFATAL, "`incbin': unable to seek on file `%s'", error(ERR_NONFATAL, "`incbin': unable to seek on file `%s'",
fname); fname);
fclose(fp);
} else { } else {
static char buf[4096]; static char buf[4096];
size_t t = instruction->times; size_t t = instruction->times;

View File

@ -1275,12 +1275,14 @@ int main(int argc, char **argv)
if ((p = strchr(buf, '\n')) != NULL) if ((p = strchr(buf, '\n')) != NULL)
*p = '\0'; *p = '\0';
if (i >= 128) { if (i >= 128) {
fclose(f);
fprintf(stderr, "ldrdf: too many input files\n"); fprintf(stderr, "ldrdf: too many input files\n");
exit(1); exit(1);
} }
*(respstrings + i) = newstr(buf); *(respstrings + i) = newstr(buf);
argc++, i++; argc++, i++;
} }
fclose(f);
break; break;
} }
case '2': case '2':

View File

@ -94,6 +94,7 @@ rdfmodule *rdfload(const char *filename)
if (f->d) if (f->d)
free(f->d); free(f->d);
free(f); free(f);
free(hdr);
return NULL; return NULL;
} }

View File

@ -59,7 +59,7 @@ char *rdl_errors[5] = {
int rdl_verify(const char *filename) int rdl_verify(const char *filename)
{ {
FILE *fp = fopen(filename, "rb"); FILE *fp;
char buf[257]; char buf[257];
int i; int i;
int32_t length; int32_t length;
@ -69,6 +69,7 @@ int rdl_verify(const char *filename)
if (lastresult != -1 && !strcmp(filename, lastverified)) if (lastresult != -1 && !strcmp(filename, lastverified))
return lastresult; return lastresult;
fp = fopen(filename, "rb");
strcpy(lastverified, filename); strcpy(lastverified, filename);
if (!fp) if (!fp)