X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fjoin.c;h=aae6a313e3bbcd5a6daaf7f436f84e0c4d83c03e;hb=87a0d455554a9e06bc47457981e370c06b9bcbac;hp=d32fc1fe936c2f364965fa7a6fa1a31eb87c22e2;hpb=16e3b6e5615abcefc9e5bb9607e2804b64d19cc2;p=wimlib diff --git a/src/join.c b/src/join.c index d32fc1fe..aae6a313 100644 --- a/src/join.c +++ b/src/join.c @@ -280,22 +280,17 @@ static int join_wims(WIMStruct **swms, uint num_swms, WIMStruct *joined_wim, WIMLIBAPI int wimlib_join(const char **swm_names, unsigned num_swms, const char *output_path, int flags) { - int i; int ret; - int part_idx; int write_flags = 0; WIMStruct *joined_wim = NULL; WIMStruct *swms[num_swms]; - int ctype; - u8 *guid; - if (num_swms < 1) return WIMLIB_ERR_INVALID_PARAM; ZERO_ARRAY(swms); - for (i = 0; i < num_swms; i++) { + for (unsigned i = 0; i < num_swms; i++) { ret = wimlib_open_wim(swm_names[i], flags | WIMLIB_OPEN_FLAG_SPLIT_OK, &swms[i]); if (ret != 0) @@ -329,14 +324,13 @@ WIMLIBAPI int wimlib_join(const char **swm_names, unsigned num_swms, goto out; ret = join_wims(swms, num_swms, joined_wim, write_flags); out: - 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. */ - if (swms[i]) { - swms[i]->out_fp = NULL; - wimlib_free(swms[i]); - } + /* out_fp is the same in all the swms and joined_wim. And it was + * already closed in the call to finish_write(). */ + for (unsigned i = 0; i < num_swms; i++) { + swms[i]->out_fp = NULL; + wimlib_free(swms[i]); } + joined_wim->out_fp = NULL; wimlib_free(joined_wim); return ret; }