Skip to content

Commit f08628a

Browse files
committed
Scan Build Fixes
1. In the echoserver, free the thread context before exiting app on error. 2. In the unit test, when checking the KDF, initialize the sizes to zero and the pointers to NULL after freeing them.
1 parent ae75319 commit f08628a

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

examples/echoserver/echoserver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
746746

747747
ssh = wolfSSH_new(ctx);
748748
if (ssh == NULL) {
749+
free(threadCtx);
749750
fprintf(stderr, "Couldn't allocate SSH data.\n");
750751
exit(EXIT_FAILURE);
751752
}

tests/unit.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static int test_KDF(void)
317317
byte* h = NULL;
318318
byte* sId = NULL;
319319
byte* eKey = NULL;
320-
word32 kSz, hSz, sIdSz, eKeySz;
320+
word32 kSz = 0, hSz = 0, sIdSz = 0, eKeySz = 0;
321321
byte cKey[32]; /* Greater of SHA256_DIGEST_SIZE and AES_BLOCK_SIZE */
322322
/* sId - Session ID, eKey - Expected Key, cKey - Calculated Key */
323323

@@ -347,6 +347,10 @@ static int test_KDF(void)
347347
}
348348

349349
FreeBins(k, h, sId, eKey);
350+
k = NULL;
351+
h = NULL;
352+
sId = NULL;
353+
eKey = NULL;
350354

351355
if (result != 0) break;
352356
}

0 commit comments

Comments
 (0)