s4-cifsdd: Don't leak memory.
[gd/samba-autobuild/.git] / source4 / client / cifsdd.c
index dd6f1377e820a524de37d20f1e8df47f11d29faf..7d412a5d807d24b3b02f3271a816483169d50b48 100644 (file)
@@ -448,6 +448,7 @@ static int copy_files(struct tevent_context *ev, struct loadparm_context *lp_ctx
                                lpcfg_socket_options(lp_ctx),
                                &session_options, 
                                lpcfg_gensec_settings(lp_ctx, lp_ctx)))) {
+               SAFE_FREE(iobuf);
                return(FILESYS_EXIT_CODE);
        }
 
@@ -456,6 +457,7 @@ static int copy_files(struct tevent_context *ev, struct loadparm_context *lp_ctx
                                lpcfg_socket_options(lp_ctx),
                                &session_options,
                                lpcfg_gensec_settings(lp_ctx, lp_ctx)))) {
+               SAFE_FREE(iobuf);
                return(FILESYS_EXIT_CODE);
        }
 
@@ -487,6 +489,7 @@ static int copy_files(struct tevent_context *ev, struct loadparm_context *lp_ctx
                        while (data_size > 0) {
                                if (!dd_flush_block(ofile, iobuf,
                                                        &data_size, obs)) {
+                                       SAFE_FREE(iobuf);
                                        return(IOERROR_EXIT_CODE);
                                }
                        }
@@ -497,6 +500,7 @@ static int copy_files(struct tevent_context *ev, struct loadparm_context *lp_ctx
                 * out one of obs bytes.
                 */
                if (!dd_fill_block(ifile, iobuf, &data_size, obs, ibs)) {
+                       SAFE_FREE(iobuf);
                        return(IOERROR_EXIT_CODE);
                }
 
@@ -520,11 +524,13 @@ static int copy_files(struct tevent_context *ev, struct loadparm_context *lp_ctx
                 */
                if (data_size && 
                    !dd_flush_block(ofile, iobuf, &data_size, obs)) {
+                       SAFE_FREE(iobuf);
                        return(IOERROR_EXIT_CODE);
                }
        }
 
 done:
+       SAFE_FREE(iobuf);
        print_transfer_stats();
        return(0);
 }