Skip to content

Commit

Permalink
Free resources if certificate cannot be found
Browse files Browse the repository at this point in the history
In find_certificate_by_callback, function return -1 directly without
free resource if node is null, that will lead to nss shut down failed.

The error message as below:
could not shut down NSS: NSS could not shutdown. Objects are still in use.

To fix this issue, free all resources before function return -1.

Signed-off-by: Chenxi Mao <[email protected]>
  • Loading branch information
Chenxi Mao committed Dec 13, 2022
1 parent 280d16d commit d8ea40d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cms_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,12 @@ find_certificate_by_callback(cms_context *cms,
}
}

if (!node)
if (!node) {
PK11_DestroySlotListElement(slots, &psle);
PK11_FreeSlotList(slots);
CERT_DestroyCertList(certlist);
cnreterr(-1, cms, "Could not find certificate");
}

*cert = CERT_DupCertificate(node->cert);

Expand Down

0 comments on commit d8ea40d

Please sign in to comment.