Skip to content

Commit 13521f8

Browse files
synaretevlendec
authored andcommitted
s3:auth: Fix Coverity ID 1646934: memory leak in make_pw_chat
make_pw_chat may succeed in the first call to SMB_CALLOC_ARRAY but fail in one of the following loop iterations, in which the list is already populated with dynamically allocated entries. Make sure that we free the list before bailing out with NULL. Fixes Coverity issue 1646934 Signed-off-by: Shachar Sharon <ssharon@redhat.com> Reviewed-by: Anoop C S <anoopcs@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Sat Jun 14 07:41:48 UTC 2025 on atb-devel-224
1 parent 08d3de9 commit 13521f8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

source3/auth/pampass.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ struct chat_struct {
223223
fstring reply;
224224
};
225225

226+
static void free_pw_chat(struct chat_struct *list);
227+
226228
/**************************************************************
227229
Create a linked list containing chat data.
228230
***************************************************************/
@@ -239,6 +241,7 @@ static struct chat_struct *make_pw_chat(const char *p)
239241
t = SMB_CALLOC_ARRAY(struct chat_struct, 1);
240242
if (!t) {
241243
DEBUG(0,("make_pw_chat: malloc failed!\n"));
244+
free_pw_chat(list);
242245
TALLOC_FREE(frame);
243246
return NULL;
244247
}

0 commit comments

Comments
 (0)