Skip to content

Commit c0ce258

Browse files
committed
Fix incorrect outbuf freeing
1 parent 0d4471f commit c0ce258

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

ext/openssl/openssl.c

-8
Original file line numberDiff line numberDiff line change
@@ -6674,10 +6674,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(char *data, size_t data_len, ch
66746674
&iv, &iv_len, &free_iv, NULL, tag_len, options, 1) == FAILURE ||
66756675
php_openssl_cipher_update(cipher_type, cipher_ctx, &mode, &outbuf, &outlen,
66766676
data, data_len, aad, aad_len, 1) == FAILURE) {
6677-
if (outbuf)
6678-
zend_string_release_ex(outbuf, 0);
66796677
outbuf = NULL;
6680-
goto cleanup;
66816678
} else if (EVP_EncryptFinal(cipher_ctx, (unsigned char *)ZSTR_VAL(outbuf) + outlen, &i)) {
66826679
outlen += i;
66836680
if (options & OPENSSL_RAW_DATA) {
@@ -6718,7 +6715,6 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(char *data, size_t data_len, ch
67186715
outbuf = NULL;
67196716
}
67206717

6721-
cleanup:
67226718
if (free_password) {
67236719
efree(password);
67246720
}
@@ -6799,10 +6795,7 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(char *data, size_t data_len, ch
67996795
&iv, &iv_len, &free_iv, tag, tag_len, options, 0) == FAILURE ||
68006796
php_openssl_cipher_update(cipher_type, cipher_ctx, &mode, &outbuf, &outlen,
68016797
data, data_len, aad, aad_len, 0) == FAILURE) {
6802-
if (outbuf)
6803-
zend_string_release_ex(outbuf, 0);
68046798
outbuf = NULL;
6805-
goto cleanup;
68066799
} else if (mode.is_single_run_aead ||
68076800
EVP_DecryptFinal(cipher_ctx, (unsigned char *)ZSTR_VAL(outbuf) + outlen, &i)) {
68086801
outlen += i;
@@ -6814,7 +6807,6 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(char *data, size_t data_len, ch
68146807
outbuf = NULL;
68156808
}
68166809

6817-
cleanup:
68186810
if (free_password) {
68196811
efree(password);
68206812
}

0 commit comments

Comments
 (0)