1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s3:libsmb: Return early if dir is NULL

This makes sure we do not dereference a NULL poineter.

Found by covscan.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Nov 26 11:07:09 UTC 2020 on sn-devel-184
This commit is contained in:
Andreas Schneider 2020-11-25 13:01:46 +01:00 committed by Andreas Schneider
parent 6d021d64c6
commit 1a86474912

View File

@ -1041,14 +1041,19 @@ int
SMBC_closedir_ctx(SMBCCTX *context,
SMBCFILE *dir)
{
TALLOC_CTX *frame = talloc_stackframe();
TALLOC_CTX *frame = NULL;
if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
return -1;
}
if (dir == NULL) {
return 0;
}
frame = talloc_stackframe();
if (!SMBC_dlist_contains(context->internal->files, dir)) {
errno = EBADF;
TALLOC_FREE(frame);
@ -1060,11 +1065,8 @@ SMBC_closedir_ctx(SMBCCTX *context,
DLIST_REMOVE(context->internal->files, dir);
if (dir) {
SAFE_FREE(dir->fname);
SAFE_FREE(dir); /* Free the space too */
}
TALLOC_FREE(frame);
return 0;