Skip to content

Commit c24b187

Browse files
fixes for clang-tidy warnings
1 parent a07d92d commit c24b187

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

wolfcrypt/src/pkcs7.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,6 +2537,9 @@ static int wc_PKCS7_EncodeContentStream(PKCS7* pkcs7, ESD* esd, void* aes,
25372537
if (cipherType == WC_CIPHER_NONE && esd && esd->contentDigestSet != 1) {
25382538
/* calculate hash for content */
25392539
ret = wc_HashInit(&esd->hash, esd->hashType);
2540+
if (ret != 0) {
2541+
return ret;
2542+
}
25402543
}
25412544

25422545
encContentOut = XMALLOC(BER_OCTET_LENGTH + MAX_OCTET_STR_SZ,
@@ -2596,6 +2599,11 @@ static int wc_PKCS7_EncodeContentStream(PKCS7* pkcs7, ESD* esd, void* aes,
25962599
ret = wc_PKCS7_EncodeContentStreamHelper(pkcs7, cipherType,
25972600
aes, encContentOut, contentData, BER_OCTET_LENGTH, out,
25982601
&outIdx, esd);
2602+
if (ret != 0) {
2603+
XFREE(encContentOut, heap, DYNAMIC_TYPE_PKCS7);
2604+
XFREE(contentData, heap, DYNAMIC_TYPE_PKCS7);
2605+
return ret;
2606+
}
25992607

26002608
/* copy over any remaining data */
26012609
XMEMCPY(contentData, buf + sz, contentDataRead);
@@ -2628,11 +2636,13 @@ static int wc_PKCS7_EncodeContentStream(PKCS7* pkcs7, ESD* esd, void* aes,
26282636
/* encrypt and flush out remainder of content data */
26292637
ret = wc_PKCS7_EncodeContentStreamHelper(pkcs7, cipherType, aes,
26302638
encContentOut, contentData, idx, out, &outIdx, esd);
2631-
2632-
if (cipherType == WC_CIPHER_NONE && esd && esd->contentDigestSet != 1) {
2633-
ret = wc_HashFinal(&esd->hash, esd->hashType,
2634-
esd->contentDigest + 2);
2635-
wc_HashFree(&esd->hash, esd->hashType);
2639+
if (ret == 0) {
2640+
if (cipherType == WC_CIPHER_NONE && esd &&
2641+
esd->contentDigestSet != 1) {
2642+
ret = wc_HashFinal(&esd->hash, esd->hashType,
2643+
esd->contentDigest + 2);
2644+
wc_HashFree(&esd->hash, esd->hashType);
2645+
}
26362646
}
26372647

26382648
XFREE(encContentOut, heap, DYNAMIC_TYPE_PKCS7);

0 commit comments

Comments
 (0)