Skip to content

Commit 5e46f08

Browse files
olszomalmtrojnar
authored andcommitted
Improve error handling in UTIL_CTX_new(), CID 457491
1 parent 71b96e1 commit 5e46f08

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/util_uri.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ struct util_ctx_st {
8181

8282
UTIL_CTX *UTIL_CTX_new()
8383
{
84-
UTIL_CTX *ctx;
84+
UTIL_CTX *ctx = OPENSSL_malloc(sizeof(UTIL_CTX));
8585

86-
ctx = OPENSSL_malloc(sizeof(UTIL_CTX));
87-
if (ctx)
88-
memset(ctx, 0, sizeof(UTIL_CTX));
86+
if (!ctx)
87+
return NULL;
88+
89+
memset(ctx, 0, sizeof(UTIL_CTX));
8990
pthread_mutex_init(&ctx->lock, 0);
9091
return ctx;
9192
}

0 commit comments

Comments
 (0)