aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordan <[email protected]>2023-05-30 18:34:09 -0400
committerdan <[email protected]>2023-05-30 18:34:09 -0400
commit212a2f0dc7f6c21b115d9f659fe769c2dba9337c (patch)
tree4fd1d7613a4b8c24062db9b79f7f1fcff02eb86f
parentbd2dac86684aaf5d4d469abcb5659b6535cea919 (diff)
downloadforth-212a2f0dc7f6c21b115d9f659fe769c2dba9337c.tar.gz
forth-212a2f0dc7f6c21b115d9f659fe769c2dba9337c.tar.bz2
forth-212a2f0dc7f6c21b115d9f659fe769c2dba9337c.zip
fix: clear outputbuffer properly
-rw-r--r--forth.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/forth.c b/forth.c
index 14c285f..3250aa7 100644
--- a/forth.c
+++ b/forth.c
@@ -90,11 +90,9 @@ char* buffer_eval(int len, char* line) {
s = stack_new();
initialised = true;
outputline = 0;
+ outputbuffer = malloc(sizeof(char) * 1024);
}
- else {
- free(outputbuffer);
- }
- outputbuffer = malloc(sizeof(char) * 1024);
+ strcpy(outputbuffer, "");
eval(ot, s, len, line);
if (outputline) {
outputline = 0;