]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
write disk windows: Release memory on error paths
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 31 May 2025 09:31:50 +0000 (11:31 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 31 May 2025 09:31:50 +0000 (11:31 +0200)
Free wsp in case of out of memory condition.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libarchive/archive_write_disk_windows.c

index c9f10a8ae793061c38327076b353ba9cae14b35a..98c7a223abb547c21f53076d66989ad1ebf9c8ac 100644 (file)
@@ -471,8 +471,10 @@ permissive_name_w(struct archive_write_disk *a)
         */
        if (wnp[0] == L'\\') {
                wn = _wcsdup(wnp);
-               if (wn == NULL)
+               if (wn == NULL) {
+                       free(wsp);
                        return (-1);
+               }
                archive_wstring_ensure(&(a->_name_data),
                        4 + 2 + wcslen(wn) + 1);
                a->name = a->_name_data.s;
@@ -486,8 +488,10 @@ permissive_name_w(struct archive_write_disk *a)
        }
 
        wn = _wcsdup(wnp);
-       if (wn == NULL)
+       if (wn == NULL) {
+               free(wsp);
                return (-1);
+       }
        archive_wstring_ensure(&(a->_name_data), 4 + l + 1 + wcslen(wn) + 1);
        a->name = a->_name_data.s;
        /* Prepend "\\?\" and drive name if not already added. */