From 067465a7695f0f041437e2b222a54b574eccd2e5 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 22 May 2013 10:28:29 -0500 Subject: [PATCH] overwrite_wim_inplace(): Fix error path --- src/write.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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; } -- 2.43.0