]> wimlib.net Git - wimlib/commitdiff
win32_capture.c: Fix memory leak in error path
authorEric Biggers <ebiggers3@gmail.com>
Sat, 5 Jul 2014 19:24:04 +0000 (14:24 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 5 Jul 2014 19:24:04 +0000 (14:24 -0500)
src/win32_capture.c

index 08a0654f812ac18573a3b22b049962998bd3c41a..4c901acb8fab1a7a931ed0a474f7f039f2ef94d7 100644 (file)
@@ -1415,18 +1415,19 @@ win32_build_dentry_tree(struct wim_dentry **root_ret,
        {
                ERROR("\"%ls\": unrecognized path format", root_disk_path);
                ret = WIMLIB_ERR_INVALID_PARAM;
-               goto out_free_path;
-       }
-
-       ntpath_nchars = ntpath.Length / sizeof(wchar_t);
-       wmemcpy(path, ntpath.Buffer, ntpath_nchars);
-       path[ntpath_nchars] = L'\0';
-
-       params->capture_root_nchars = ntpath_nchars;
-       if (path[ntpath_nchars - 1] == L'\\')
-               params->capture_root_nchars--;
+       } else {
+               ntpath_nchars = ntpath.Length / sizeof(wchar_t);
+               wmemcpy(path, ntpath.Buffer, ntpath_nchars);
+               path[ntpath_nchars] = L'\0';
 
+               params->capture_root_nchars = ntpath_nchars;
+               if (path[ntpath_nchars - 1] == L'\\')
+                       params->capture_root_nchars--;
+               ret = 0;
+       }
        HeapFree(GetProcessHeap(), 0, ntpath.Buffer);
+       if (ret)
+               goto out_free_path;
 
        memset(&stats, 0, sizeof(stats));