Commit bea80198 authored by Jimmy Brisson's avatar Jimmy Brisson Committed by Manish Pandey
Browse files

Free X509_EXTENSIONs



Previously, we would leak these extensions as they are not freed by the
stack. An except from the `sk_TYPE_free` documentation:

    sk_TYPE_free() frees up the sk structure. It does not free up any
    elements of sk. After this call sk is no longer valid.

The fix is to drain the stack and free its elements before freeing the
stack. sk_TYPE_pop_free does this, so we use that instead.

Change-Id: Ie70c302f9dda5af1a7243f163d36e99916ee639c
Signed-off-by: default avatarJimmy Brisson <jimmy.brisson@arm.com>
parent 32269499
......@@ -539,6 +539,11 @@ int main(int argc, char *argv[])
exit(1);
}
for (cert_ext = sk_X509_EXTENSION_pop(sk); cert_ext != NULL;
cert_ext = sk_X509_EXTENSION_pop(sk)) {
X509_EXTENSION_free(cert_ext);
}
sk_X509_EXTENSION_free(sk);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment