@@ -175,7 +175,7 @@ int wc_Sha256Final(wc_Sha256* sha, byte* hash)
175175 ret = GetDigest (sha , CRYPTO_SHA2_256 , hash );
176176 if (ret != 0 ) {
177177 wc_Sha256Free (sha );
178- return ret ;
178+ return ret ;
179179 }
180180
181181 wc_Sha256Free (sha );
@@ -199,9 +199,10 @@ int wc_Sha256GetHash(wc_Sha256* sha, byte* hash)
199199 * in wc_Sha256Copy() does not close fd 0 (cfd == -1 is the
200200 * "no session" sentinel, matching wc_AesInit()) */
201201 cpy .ctx .cfd = -1 ;
202- wc_Sha256Copy (sha , & cpy );
202+ ret = wc_Sha256Copy (sha , & cpy );
203203
204- if ((ret = HashUpdate (& cpy , CRYPTO_SHA2_256 , cpy .msg , cpy .used )) == 0 ) {
204+ if (ret == 0 &&
205+ (ret = HashUpdate (& cpy , CRYPTO_SHA2_256 , cpy .msg , cpy .used )) == 0 ) {
205206 /* help static analysis tools out */
206207 XMEMSET (hash , 0 , WC_SHA256_DIGEST_SIZE );
207208 ret = GetDigest (& cpy , CRYPTO_SHA2_256 , hash );
@@ -225,9 +226,9 @@ int wc_Sha256Copy(wc_Sha256* src, wc_Sha256* dst)
225226 return BAD_FUNC_ARG ;
226227 }
227228
229+ #ifdef WOLFSSL_DEVCRYPTO_HASH_KEEP
228230 wc_Sha256Free (dst );
229231 wc_InitSha256_ex (dst , src -> heap , 0 );
230- #ifdef WOLFSSL_DEVCRYPTO_HASH_KEEP
231232 dst -> len = src -> len ;
232233 dst -> used = src -> used ;
233234 dst -> msg = (byte * )XMALLOC (src -> len , dst -> heap , DYNAMIC_TYPE_TMP_BUFFER );
0 commit comments