Skip to content

Commit 6e70a07

Browse files
fix for handling memory on socket timeout
1 parent 563e6c4 commit 6e70a07

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

apps/wolfsshd/wolfsshd.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,9 +2468,11 @@ static int StartSSHD(int argc, char** argv)
24682468
struct sockaddr_in6 clientAddr;
24692469
socklen_t clientAddrSz = sizeof(clientAddr);
24702470
#endif
2471-
conn = (WOLFSSHD_CONNECTION*)WMALLOC(sizeof(WOLFSSHD_CONNECTION), NULL, DYNTYPE_SSHD);
2471+
conn = (WOLFSSHD_CONNECTION*)WMALLOC(sizeof(WOLFSSHD_CONNECTION),
2472+
NULL, DYNTYPE_SSHD);
24722473
if (conn == NULL) {
2473-
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Failed to malloc memory for connection");
2474+
wolfSSH_Log(WS_LOG_ERROR,
2475+
"[SSHD] Failed to malloc memory for connection");
24742476
break;
24752477
}
24762478

@@ -2536,9 +2538,13 @@ static int StartSSHD(int argc, char** argv)
25362538
}
25372539
ret = NewConnection(conn);
25382540
}
2541+
else {
2542+
XFREE(conn, NULL, DYNTYPE_SSHD);
2543+
}
25392544
#ifdef _WIN32
25402545
/* check if service has been shutdown */
2541-
if (isDaemon && WaitForSingleObject(serviceStop, 0) == WAIT_OBJECT_0) {
2546+
if (isDaemon && WaitForSingleObject(serviceStop, 0) ==
2547+
WAIT_OBJECT_0) {
25422548
quit = 1;
25432549
}
25442550
#endif

0 commit comments

Comments
 (0)