Skip to content

Commit 73e4259

Browse files
setting heap pointer based on if key is null
1 parent 9b96f49 commit 73e4259

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12374,14 +12374,16 @@ int wc_DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey* key,
1237412374
/* dsaPubKeyASN is longer than dsaPublicKeyASN. */
1237512375
DECL_ASNGETDATA(dataASN, dsaPubKeyASN_Length);
1237612376
int ret = 0;
12377+
void* heap = NULL;
1237712378

1237812379
/* Validated parameters. */
1237912380
if ((input == NULL) || (inOutIdx == NULL) || (key == NULL)) {
1238012381
ret = BAD_FUNC_ARG;
1238112382
}
12383+
heap = (key != NULL) ? key->heap : NULL;
1238212384

1238312385
if (ret == 0) {
12384-
ALLOC_ASNGETDATA(dataASN, dsaPubKeyASN_Length, ret, key->heap);
12386+
ALLOC_ASNGETDATA(dataASN, dsaPubKeyASN_Length, ret, heap);
1238512387
}
1238612388

1238712389
if (ret == 0) {
@@ -12420,7 +12422,7 @@ int wc_DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey* key,
1242012422
key->type = DSA_PUBLIC;
1242112423
}
1242212424

12423-
FREE_ASNGETDATA(dataASN, key->heap);
12425+
FREE_ASNGETDATA(dataASN, heap);
1242412426
return ret;
1242512427
#endif
1242612428
}
@@ -37536,6 +37538,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
3753637538
/* eccKeyASN is longer than eccPublicKeyASN. */
3753737539
DECL_ASNGETDATA(dataASN, eccKeyASN_Length);
3753837540
int ret = 0;
37541+
void* heap = NULL;
3753937542
int curve_id = ECC_CURVE_DEF;
3754037543
int oidIdx = ECCPUBLICKEYASN_IDX_ALGOID_CURVEID;
3754137544
#ifdef WOLFSSL_CUSTOM_CURVES
@@ -37546,9 +37549,10 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
3754637549
if ((input == NULL) || (inOutIdx == NULL) || (key == NULL) || (inSz == 0)) {
3754737550
ret = BAD_FUNC_ARG;
3754837551
}
37552+
heap = (key != NULL) ? key->heap : NULL;
3754937553

3755037554
if (ret == 0) {
37551-
ALLOC_ASNGETDATA(dataASN, eccKeyASN_Length, ret, key->heap);
37555+
ALLOC_ASNGETDATA(dataASN, eccKeyASN_Length, ret, heap);
3755237556
}
3755337557

3755437558
if (ret == 0) {
@@ -37622,7 +37626,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
3762237626
}
3762337627
}
3762437628

37625-
FREE_ASNGETDATA(dataASN, key->heap);
37629+
FREE_ASNGETDATA(dataASN, heap);
3762637630
return ret;
3762737631
#endif /* WOLFSSL_ASN_TEMPLATE */
3762837632
}

0 commit comments

Comments
 (0)