Skip to content

Commit 12a5cb4

Browse files
committed
separating two x509_store xmalloc checks
1 parent d28dd60 commit 12a5cb4

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/internal.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,19 +2460,21 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap)
24602460
return MEMORY_E;
24612461
}
24622462
XMEMSET(ctx->param, 0, sizeof(WOLFSSL_X509_VERIFY_PARAM));
2463-
/* WOLFSSL_X509_LOOKUP and param */
2464-
if ((ctx->x509_store.lookup.dirs =
2465-
(WOLFSSL_BY_DIR*)XMALLOC(sizeof(WOLFSSL_BY_DIR),
2466-
heap, DYNAMIC_TYPE_OPENSSL)) == NULL ||
2467-
(ctx->x509_store.param = (WOLFSSL_X509_VERIFY_PARAM*)XMALLOC(
2468-
sizeof(WOLFSSL_X509_VERIFY_PARAM),
2469-
heap, DYNAMIC_TYPE_OPENSSL)) == NULL) {
2470-
WOLFSSL_MSG("ctx-x509_store.lookup.dir or ctx->x509_store.param memory "
2471-
"allocation error");
2463+
2464+
/* WOLFSSL_X509_LOOKUP */
2465+
if ((ctx->x509_store.lookup.dirs = (WOLFSSL_BY_DIR*)XMALLOC(sizeof(WOLFSSL_BY_DIR), heap, DYNAMIC_TYPE_OPENSSL)) == NULL) {
2466+
WOLFSSL_MSG("ctx-x509_store.lookup.dirs: allocation error");
24722467
return MEMORY_E;
24732468
}
24742469
XMEMSET(ctx->x509_store.lookup.dirs, 0, sizeof(WOLFSSL_BY_DIR));
2470+
2471+
/* param */
2472+
if ((ctx->x509_store.param = (WOLFSSL_X509_VERIFY_PARAM*)XMALLOC(sizeof(WOLFSSL_X509_VERIFY_PARAM), heap, DYNAMIC_TYPE_OPENSSL)) == NULL) {
2473+
WOLFSSL_MSG("ctx->x509_store.param: allocation error");
2474+
return MEMORY_E;
2475+
}
24752476
XMEMSET(ctx->x509_store.param, 0, sizeof(WOLFSSL_X509_VERIFY_PARAM));
2477+
24762478
if (wc_InitMutex(&ctx->x509_store.lookup.dirs->lock) != 0) {
24772479
WOLFSSL_MSG("Bad mutex init");
24782480
WOLFSSL_ERROR_VERBOSE(BAD_MUTEX_E);

0 commit comments

Comments
 (0)