fix: move ownership of line to oldline
- set line to null when moved - also, free line when loading from history
This commit is contained in:
@@ -357,6 +357,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
oldline = line;
|
||||
line = NULL;
|
||||
}
|
||||
} else if (ansi == ANSI_CURSOR_DOWN && historyoffset > 0) {
|
||||
historyoffset--;
|
||||
@@ -383,6 +384,11 @@ int main(int argc, char** argv) {
|
||||
if (load_from_hist == 1) {
|
||||
char* historyline = history[historyi - (historyoffset)];
|
||||
size_t historylinelen = strlen(historyline);
|
||||
|
||||
if (line != NULL) {
|
||||
free(line);
|
||||
}
|
||||
|
||||
line = malloc(historylinelen + 1);
|
||||
if (line == NULL) {
|
||||
retval = 1;
|
||||
|
||||
Reference in New Issue
Block a user