From: Eric Biggers Date: Wed, 22 May 2013 15:28:29 +0000 (-0500) Subject: overwrite_wim_inplace(): Fix error path X-Git-Tag: v1.4.1~26 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=067465a7695f0f041437e2b222a54b574eccd2e5 overwrite_wim_inplace(): Fix error path --- diff --git a/src/write.c b/src/write.c index b1d8708f..3b2aa18e 100644 --- a/src/write.c +++ b/src/write.c @@ -2116,14 +2116,16 @@ overwrite_wim_inplace(WIMStruct *w, int write_flags, w->hdr.flags |= WIM_HDR_FLAG_WRITE_IN_PROGRESS; ret = write_header(&w->hdr, w->out_fd); w->hdr.flags &= ~WIM_HDR_FLAG_WRITE_IN_PROGRESS; - if (ret) - return ret; + if (ret) { + close_wim_writable(w); + goto out_unlock_wim; + } if (lseek(w->out_fd, old_wim_end, SEEK_SET) == -1) { ERROR_WITH_ERRNO("Can't seek to end of WIM"); close_wim_writable(w); - w->wim_locked = 0; - return WIMLIB_ERR_WRITE; + ret = WIMLIB_ERR_WRITE; + goto out_unlock_wim; } DEBUG("Writing newly added streams (offset = %"PRIu64")", @@ -2158,6 +2160,7 @@ out_truncate: * an error path. */ (void)ttruncate(w->filename, old_wim_end); } +out_unlock_wim: w->wim_locked = 0; return ret; }