1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-27 12:35:13 +00:00

Fix some very mild memory leaks in line.c and the do_bytes function (not

deiniting the parser).
This commit is contained in:
Calvin Rose
2018-05-15 22:03:45 -04:00
parent c6f79eca6d
commit 6ac59251e9
4 changed files with 106 additions and 63 deletions

View File

@@ -265,6 +265,8 @@ static void addhistory() {
if (len < DST_HISTORY_MAX) {
dst_v_push(history, newline);
len++;
} else {
free(history[DST_HISTORY_MAX - 1]);
}
for (i = len - 1; i > 0; i--) {
history[i] = history[i - 1];
@@ -275,6 +277,7 @@ static void addhistory() {
static void replacehistory() {
char *newline = sdup(buf);
if (!newline) return;
free(history[0]);
history[0] = newline;
}