Skip to content

Commit c79167c

Browse files
lePicimichalvasko
authored andcommitted
cli BUGFIX memory leak in linenoise and readinput
1 parent 18a2e17 commit c79167c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cli/completion.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,15 @@ readinput(const char *instruction, const char *old_tmp, char **new_tmp)
323323
}
324324
}
325325

326+
cleanup:
327+
326328
if (new_tmp) {
327329
*new_tmp = tmpname;
328330
} else {
329331
unlink(tmpname);
330332
free(tmpname);
331333
}
332334

333-
cleanup:
334-
335335
close(tmpfd);
336336
free(old_content);
337337

cli/linenoise/linenoise.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,10 @@ char *linenoiseHistoryDataGet() {
10441044

10451045
static void linenoiseHistItemFree(int hist_idx) {
10461046
free(history[hist_idx].line);
1047+
history[hist_idx].line = NULL;
10471048
if (hist_data_free_clb) {
10481049
hist_data_free_clb(history[hist_idx].data);
1050+
history[hist_idx].data = NULL;
10491051
}
10501052
}
10511053

0 commit comments

Comments
 (0)