Skip to content

Commit

Permalink
cli BUGFIX memory leak in linenoise and readinput
Browse files Browse the repository at this point in the history
  • Loading branch information
lePici authored and michalvasko committed Jan 7, 2025
1 parent 18a2e17 commit c79167c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli/completion.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,15 @@ readinput(const char *instruction, const char *old_tmp, char **new_tmp)
}
}

cleanup:

if (new_tmp) {
*new_tmp = tmpname;
} else {
unlink(tmpname);
free(tmpname);
}

cleanup:

close(tmpfd);
free(old_content);

Expand Down
2 changes: 2 additions & 0 deletions cli/linenoise/linenoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,8 +1044,10 @@ char *linenoiseHistoryDataGet() {

static void linenoiseHistItemFree(int hist_idx) {
free(history[hist_idx].line);
history[hist_idx].line = NULL;
if (hist_data_free_clb) {
hist_data_free_clb(history[hist_idx].data);
history[hist_idx].data = NULL;
}
}

Expand Down

0 comments on commit c79167c

Please sign in to comment.