Skip to content

Commit

Permalink
(xmlsec-openssl) Fix memory leak if file doesn't exist (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsh123 authored Jul 1, 2024
1 parent 548c71e commit ea542d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/openssl/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ xmlSecOpenSSLAppKeyLoadEx(const char *filename, xmlSecKeyDataType type, xmlSecKe
if(key == NULL) {
xmlSecInternalError2("xmlSecOpenSSLAppKeyLoadBIO", NULL,
"filename=%s", xmlSecErrorsSafeString(filename));
BIO_free(bio);
BIO_free_all(bio);
return(NULL);
}

BIO_free(bio);
BIO_free_all(bio);
}

return(key);
Expand Down Expand Up @@ -309,11 +309,11 @@ xmlSecOpenSSLAppKeyLoadMemory(const xmlSecByte* data, xmlSecSize dataSize,
key = xmlSecOpenSSLAppKeyLoadBIO (bio, format, pwd, pwdCallback, pwdCallbackCtx);
if(key == NULL) {
xmlSecInternalError("xmlSecOpenSSLAppKeyLoadBIO", NULL);
BIO_free(bio);
BIO_free_all(bio);
return(NULL);
}

BIO_free(bio);
BIO_free_all(bio);
return(key);
}

Expand Down
1 change: 1 addition & 0 deletions src/openssl/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ xmlSecOpenSSLCreateReadFileBio(const char* path) {
if(BIO_read_filename(bio, path) != 1) {
xmlSecOpenSSLError2("BIO_read_filename", NULL,
"path=%s", xmlSecErrorsSafeString(path));
BIO_free_all(bio);
return(NULL);
}
return(bio);
Expand Down

0 comments on commit ea542d2

Please sign in to comment.