memory: free any allocated strings, also in the emergency code path
parent
e3ef778756
commit
c84a769733
src
12
src/nano.c
12
src/nano.c
|
@ -311,15 +311,16 @@ void do_exit(void)
|
||||||
|
|
||||||
/* Save the current buffer under the given name (or under "nano.<PID>"
|
/* Save the current buffer under the given name (or under "nano.<PID>"
|
||||||
* for a nameless buffer). If needed, the name is modified to be unique. */
|
* for a nameless buffer). If needed, the name is modified to be unique. */
|
||||||
void emergency_save(char *plainname)
|
void emergency_save(const char *filename)
|
||||||
{
|
{
|
||||||
|
char *plainname, *targetname;
|
||||||
bool saved = FALSE;
|
bool saved = FALSE;
|
||||||
char *targetname;
|
|
||||||
|
|
||||||
if (*plainname == '\0') {
|
if (*filename == '\0') {
|
||||||
plainname = nrealloc(plainname, 28);
|
plainname = nmalloc(28);
|
||||||
sprintf(plainname, "nano.%u", getpid());
|
sprintf(plainname, "nano.%u", getpid());
|
||||||
}
|
} else
|
||||||
|
plainname = copy_of(filename);
|
||||||
|
|
||||||
targetname = get_next_filename(plainname, ".save");
|
targetname = get_next_filename(plainname, ".save");
|
||||||
|
|
||||||
|
@ -345,6 +346,7 @@ void emergency_save(char *plainname)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
free(targetname);
|
free(targetname);
|
||||||
|
free(plainname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Die gracefully -- by restoring the terminal state and saving any buffers
|
/* Die gracefully -- by restoring the terminal state and saving any buffers
|
||||||
|
|
Loading…
Reference in New Issue