Skip to content

Commit

Permalink
opendir: fix leak of cb_data on session failures
Browse files Browse the repository at this point in the history
Signed-off-by: Ronnie Sahlberg <[email protected]>
  • Loading branch information
sahlberg committed Oct 6, 2024
1 parent 5304e67 commit 05eac44
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/libsmb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ free_smb2dir(struct smb2_context *smb2, struct smb2dir *dir)
free(dir->entries);
dir->entries = e;
}
free(dir->cb_data);
free(dir);
}

Expand Down
3 changes: 1 addition & 2 deletions lib/sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ static void opendir_cb(struct smb2_context *smb2, int status,
struct sync_cb_data *cb_data = private_data;

if (cb_data->status == SMB2_STATUS_CANCELLED) {
free(cb_data);
return;
}

Expand All @@ -201,6 +200,7 @@ struct smb2dir *smb2_opendir(struct smb2_context *smb2, const char *path)
return NULL;
}

/* smb2dir takes wnership of cb_data on success */
if (smb2_opendir_async(smb2, path,
opendir_cb, cb_data) != 0) {
smb2_set_error(smb2, "smb2_opendir_async failed");
Expand All @@ -214,7 +214,6 @@ struct smb2dir *smb2_opendir(struct smb2_context *smb2, const char *path)
}

ptr = cb_data->ptr;
free(cb_data);
return ptr;
}

Expand Down

0 comments on commit 05eac44

Please sign in to comment.