]> git.wh0rd.org Git - nano.git/commitdiff
apply patch from DB: in write_file(), if we've tried to write to an
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Fri, 22 Oct 2004 03:33:54 +0000 (03:33 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Fri, 22 Oct 2004 03:33:54 +0000 (03:33 +0000)
unwritable file and we're not prepending, tempname is NULL when it's
passed to unlink(); this can cause problems if unlink() can't handle
NULL, so don't call it in that case

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2012 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/files.c

index 670f5c173ca0b6a8e2858c28352178298e2fa14a..7e03e593f618057c54d9d1247223a1feb41e7d3a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -109,6 +109,11 @@ CVS code -
   do_writeout_void()
        - Call display_main_list(), for consistency with
          do_insertfile_void(). (DLR)
+  write_file()
+       - If we've tried to write to an unwritable file and we're not
+         prepending, tempname is NULL when it's passed to unlink().
+         This can cause problems if unlink() can't handle NULL, so
+         don't call it in that case. (David Benbennick)
   write_marked()
        - Remove check for MARK_ISSET's not being set. (DLR)
   open_prevfile(), open_nextfile()
index 72b84a47023afa52aa5793cf30b96f100a24bdef..cc0bf201e783ad8ad1f012cbfd369368da6011a6 100644 (file)
@@ -1602,7 +1602,9 @@ int write_file(const char *name, int tmp, int append, int nonamechange)
     /* First, just give up if we couldn't even open the file. */
     if (fd == -1) {
        statusbar(_("Error writing %s: %s"), realname, strerror(errno));
-       unlink(tempname);
+       /* tempname has been set only if we're prepending. */
+       if (tempname != NULL)
+           unlink(tempname);
        goto cleanup_and_exit;
     }