Commit 62eeda3e authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: use mallocstrcpy() instead of strdup(), for a graceful death

To make nano save its modified buffers when it runs out of memory.
No related merge requests found
Showing with 4 additions and 4 deletions
+4 -4
......@@ -315,7 +315,7 @@ char *do_browser(char *path)
present_name = striponedir(filelist[selected]);
/* Try opening and reading the selected directory. */
newpath = strdup(filelist[selected]);
newpath = mallocstrcpy(NULL, filelist[selected]);
goto read_directory_contents;
} else if (func == do_exit) {
/* Exit from the file browser. */
......@@ -331,9 +331,9 @@ char *do_browser(char *path)
/* If the window resized, refresh the file list. */
if (kbinput == KEY_WINCH) {
/* Remember the selected file, to be able to reselect it. */
present_name = strdup(filelist[selected]);
present_name = mallocstrcpy(NULL, filelist[selected]);
/* Reread the contents of the current directory. */
newpath = strdup(present_path);
newpath = mallocstrcpy(NULL, present_path);
goto read_directory_contents;
}
#endif
......
......@@ -99,7 +99,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
if (comma == str)
return TRUE;
firstpart = strdup(str);
firstpart = mallocstrcpy(NULL, str);
firstpart[comma - str] = '\0';
retval = parse_num(firstpart, line);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment