Skip to content

Commit b5c5854

Browse files
committed
fix for cppcheck defect in src/ssl.c
1 parent 6bda10a commit b5c5854

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

src/ssl.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5891,8 +5891,13 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify)
58915891
return BAD_FUNC_ARG;
58925892
}
58935893

5894-
WC_ALLOC_VAR_EX(cert, DecodedCert, 1, NULL, DYNAMIC_TYPE_DCERT,
5895-
{FreeDer(pDer);return MEMORY_E;});
5894+
#ifdef WOLFSSL_SMALL_STACK
5895+
cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_DCERT);
5896+
if (cert == NULL) {
5897+
FreeDer(pDer);
5898+
return MEMORY_E;
5899+
}
5900+
#endif
58965901

58975902
InitDecodedCert(cert, der->buffer, der->length, cm->heap);
58985903

@@ -5907,12 +5912,6 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify)
59075912

59085913
WOLFSSL_MSG("\tParsed new CA");
59095914
#ifdef WOLFSSL_DEBUG_CERTS
5910-
#ifdef WOLFSSL_SMALL_STACK
5911-
if (cert == NULL) {
5912-
WOLFSSL_MSG_CERT(WOLFSSL_MSG_CERT_INDENT "Failed; cert is NULL");
5913-
}
5914-
else
5915-
#endif
59165915
{
59175916
const char* err_msg;
59185917
if (ret == 0) {

0 commit comments

Comments
 (0)