tweaks: use mallocstrcpy() instead of strdup(), for a graceful death
To make nano save its modified buffers when it runs out of memory.master
parent
06c806215e
commit
62eeda3e9f
|
@ -315,7 +315,7 @@ char *do_browser(char *path)
|
||||||
present_name = striponedir(filelist[selected]);
|
present_name = striponedir(filelist[selected]);
|
||||||
|
|
||||||
/* Try opening and reading the selected directory. */
|
/* Try opening and reading the selected directory. */
|
||||||
newpath = strdup(filelist[selected]);
|
newpath = mallocstrcpy(NULL, filelist[selected]);
|
||||||
goto read_directory_contents;
|
goto read_directory_contents;
|
||||||
} else if (func == do_exit) {
|
} else if (func == do_exit) {
|
||||||
/* Exit from the file browser. */
|
/* Exit from the file browser. */
|
||||||
|
@ -331,9 +331,9 @@ char *do_browser(char *path)
|
||||||
/* If the window resized, refresh the file list. */
|
/* If the window resized, refresh the file list. */
|
||||||
if (kbinput == KEY_WINCH) {
|
if (kbinput == KEY_WINCH) {
|
||||||
/* Remember the selected file, to be able to reselect it. */
|
/* 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. */
|
/* Reread the contents of the current directory. */
|
||||||
newpath = strdup(present_path);
|
newpath = mallocstrcpy(NULL, present_path);
|
||||||
goto read_directory_contents;
|
goto read_directory_contents;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -99,7 +99,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
|
||||||
if (comma == str)
|
if (comma == str)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
firstpart = strdup(str);
|
firstpart = mallocstrcpy(NULL, str);
|
||||||
firstpart[comma - str] = '\0';
|
firstpart[comma - str] = '\0';
|
||||||
|
|
||||||
retval = parse_num(firstpart, line);
|
retval = parse_num(firstpart, line);
|
||||||
|
|
Loading…
Reference in New Issue