1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-07-28 01:41:48 +03:00

examples: Make sure the callback structure is initialized

When the callback structure is allocated with malloc, some fields might be
uninitialized and therefore could cause undefined behavior or crashes.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
Jakub Jelen
2024-05-31 09:15:05 +02:00
committed by Sahana Prasad
parent 70d0993312
commit c93a730bc1

View File

@ -526,7 +526,7 @@ message_callback(UNUSED_PARAM(ssh_session session),
}
pFd = malloc(sizeof *pFd);
cb_chan = malloc(sizeof *cb_chan);
cb_chan = calloc(1, sizeof *cb_chan);
event_fd_data = malloc(sizeof *event_fd_data);
if (pFd == NULL || cb_chan == NULL || event_fd_data == NULL) {
SAFE_FREE(pFd);