spkstr is not free'd when running the test and valgrind reports a leak
of 32,318 bytes. The free condition is not met since keyresource is not
NULL, apart from that OPENSSL_free actually free's the allocated memory
by OPENSSL_malloc inside OpenSSL.
Valgrind reports 768 bytes leaked in openssl_spki_new when running the
testsuite. Remove the keyresource check to always free spki.
s = zend_string_alloc(strlen(spkac) + strlen(spkstr), 0);
sprintf(ZSTR_VAL(s), "%s%s", spkac, spkstr);
ZSTR_LEN(s) = strlen(ZSTR_VAL(s));
+ OPENSSL_free(spkstr);
RETVAL_STR(s);
goto cleanup;
cleanup:
- if (keyresource == NULL && spki != NULL) {
+ if (spki != NULL) {
NETSCAPE_SPKI_free(spki);
}
if (keyresource == NULL && pkey != NULL) {
EVP_PKEY_free(pkey);
}
- if (keyresource == NULL && spkstr != NULL) {
- efree(spkstr);
- }
if (s && ZSTR_LEN(s) <= 0) {
RETVAL_FALSE;