Skip to content

Commit

Permalink
Fix potential memory leak on error in LoadCRL()
Browse files Browse the repository at this point in the history
If ProcessFile() fails, the code does not clean up readCtx.
Perform the same cleanup as after the loop to fix this.
  • Loading branch information
nielsdos committed Feb 3, 2025
1 parent 275beca commit a0e4fcb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/crl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,10 @@ int LoadCRL(WOLFSSL_CRL* crl, const char* path, int type, int monitor)
ret = ProcessFile(NULL, name, type, CRL_TYPE, NULL, 0, crl, VERIFY);
if (ret != WOLFSSL_SUCCESS) {
WOLFSSL_MSG("CRL file load failed");
wc_ReadDirClose(readCtx);
#ifdef WOLFSSL_SMALL_STACK
XFREE(readCtx, crl->heap, DYNAMIC_TYPE_TMP_BUFFER);
#endif
return ret;
}
}
Expand Down

0 comments on commit a0e4fcb

Please sign in to comment.