Fix deference NULL pointer on join error
authorEric Biggers <ebiggers3@gmail.com>
Sat, 19 May 2012 19:01:08 +0000 (14:01 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 19 May 2012 19:01:08 +0000 (14:01 -0500)
src/join.c

index b804f8f80991f50e6277e6fb89f50d70072a6e95..1326804b428482aa15667cd111f7545a1e0a191f 100644 (file)
@@ -151,7 +151,7 @@ WIMLIBAPI int wimlib_join(const char **swm_names, int num_swms,
                        }
                }
                if (w->hdr.total_parts != num_swms) {
-                       ERROR("`%s' (part %d) says there are %d total parts,\n"
+                       ERROR("`%s' (part %d) says there are %d total parts, "
                                        "but %d parts were specified!\n",
                                        swm_names[i], w->hdr.part_number,
                                        w->hdr.total_parts, num_swms);
@@ -195,8 +195,10 @@ err:
        for (i = 0; i < num_swms; i++) {
                /* out_fp is the same in all the swms and joined_wim; only close
                 * it one time, when freeing joined_wim. */
-               swms[i]->out_fp = NULL;
-               wimlib_free(swms[i]);
+               if (swms[i]) {
+                       swms[i]->out_fp = NULL;
+                       wimlib_free(swms[i]);
+               }
        }
        wimlib_free(joined_wim);
        return ret;