Skip to content

Commit f0ba67e

Browse files
authored
Merge pull request #9906 from julek-wolfssl/fenrir/25
wolfSSL_ASN1_item_i2d: simplify buf cleanup
2 parents 1d49f41 + 3c06c22 commit f0ba67e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/ssl_asn1.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ int wolfSSL_ASN1_item_i2d(const void* obj, byte** dest,
395395
{
396396
int ret = 1;
397397
int len = 0;
398-
byte* buf = NULL;
399398

400399
WOLFSSL_ENTER("wolfSSL_ASN1_item_i2d");
401400

@@ -408,6 +407,7 @@ int wolfSSL_ASN1_item_i2d(const void* obj, byte** dest,
408407
ret = 0;
409408

410409
if ((ret == 1) && (dest != NULL)) {
410+
byte* buf = NULL;
411411
if (*dest == NULL) {
412412
buf = (byte*)XMALLOC((size_t)len, NULL, DYNAMIC_TYPE_ASN1);
413413
if (buf == NULL)
@@ -428,11 +428,11 @@ int wolfSSL_ASN1_item_i2d(const void* obj, byte** dest,
428428
else
429429
*dest += len;
430430
}
431+
if (ret == 0 && *dest == NULL)
432+
XFREE(buf, NULL, DYNAMIC_TYPE_ASN1);
431433
}
432434

433435
if (ret == 0) {
434-
if (*dest == NULL)
435-
XFREE(buf, NULL, DYNAMIC_TYPE_ASN1);
436436
len = WOLFSSL_FATAL_ERROR;
437437
}
438438
WOLFSSL_LEAVE("wolfSSL_ASN1_item_i2d", len);

0 commit comments

Comments
 (0)