aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornytpu <alex@nytpu.com>2021-06-04 16:19:51 -0600
committernytpu <alex@nytpu.com>2021-06-04 16:19:51 -0600
commit12cbd9227bb26fdc8617093c63b4d077434cc35a (patch)
treec6c99b098ad1e7c01b8a24185ac40fcc9affd109
parentuse one-indexing interally unless actually indexing rows array (diff)
downloaded-12cbd9227bb26fdc8617093c63b4d077434cc35a.tar.bz2
ed-12cbd9227bb26fdc8617093c63b4d077434cc35a.zip
fix unfreed memory on q/Q command
-rw-r--r--main.c3
-rw-r--r--test.txt10
2 files changed, 2 insertions, 11 deletions
diff --git a/main.c b/main.c
index 7b224be..9a99913 100644
--- a/main.c
+++ b/main.c
@@ -91,7 +91,7 @@ main(int argc, char *argv[])
// DEBUG
printf("#: %ld; c: %ld\n", E.numrows, E.crow);
- char *line;
+ char *line = NULL;
while ((line = linenoise(E.prompt_enabled ? E.prompt : "")) != NULL) {
struct command cmd;
int ret = parse_command(&cmd, line);
@@ -114,6 +114,7 @@ main(int argc, char *argv[])
}
// fallthrough
case 'Q':
+ free(line);
goto quit;
default:
error("Unknown command");
diff --git a/test.txt b/test.txt
deleted file mode 100644
index f00c965..0000000
--- a/test.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10