Soft'N'Design Software
/
projects
/
brainfuck.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3223738
)
correct memory leaks
author
Laurent Mazet
<mazet@softndesign.org>
Fri, 22 Dec 2023 09:41:59 +0000
(10:41 +0100)
committer
Laurent Mazet
<mazet@softndesign.org>
Fri, 22 Dec 2023 09:41:59 +0000
(10:41 +0100)
bf.c
patch
|
blob
|
blame
|
history
diff --git
a/bf.c
b/bf.c
index 41882a8cd92a08995a34e018fb7a940d72aea832..e06041b8cb2949553336b80af19af951b3b6ac50 100644
(file)
--- a/
bf.c
+++ b/
bf.c
@@
-2,7
+2,7
@@
/* cflags: */
/* linker: debug.o */
/* cflags: */
/* linker: debug.o */
-#include <
assert
.h>
+#include <
errno
.h>
#include <getopt.h>
#include <malloc.h>
#include <stdio.h>
#include <getopt.h>
#include <malloc.h>
#include <stdio.h>
@@
-248,6
+248,7
@@
int main (int argc, char *argv[])
fid = fopen (output, "w");
if (fid == NULL) {
VERBOSE (ERROR, fprintf (stderr, "%s: can't open file '%s' for writing\n", progname, output));
fid = fopen (output, "w");
if (fid == NULL) {
VERBOSE (ERROR, fprintf (stderr, "%s: can't open file '%s' for writing\n", progname, output));
+ if (buffer) free (buffer);
return 1;
}
} else {
return 1;
}
} else {
@@
-262,6
+263,11
@@
int main (int argc, char *argv[])
fclose (fid);
}
fclose (fid);
}
+ /* free buffer */
+ if (buffer) {
+ free (buffer);
+ }
+
VERBOSE (INFO, fprintf (stdout, "\nmemory:"); int _i; for (_i = 0; _i < MEMSIZE; _i++) fprintf (stdout," %d", mem[_i]); fprintf (stdout,"\n"));
return rc;
VERBOSE (INFO, fprintf (stdout, "\nmemory:"); int _i; for (_i = 0; _i < MEMSIZE; _i++) fprintf (stdout," %d", mem[_i]); fprintf (stdout,"\n"));
return rc;