com php-src: Remove unnecessary resource checks in openssl ext: ext/openssl/openssl.c

From: Date: Tue, 17 Feb 2015 20:46:36 +0000
Subject: com php-src: Remove unnecessary resource checks in openssl ext: ext/openssl/openssl.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-84968@lists.php.net to get a copy of this message
Commit: 0676f39ee4f062da47255e3f477fa9857d2a0b52 Author: Jakub Zelenka <bukka@php.net> Tue, 17 Feb 2015 20:46:36 +0000 Parents: c3bd8cd8a9a0e5d2bef4bd9d2134de54fb7250b0 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0676f39ee4f062da47255e3f477fa9857d2a0b52 Log: Remove unnecessary resource checks in openssl ext The resource val is already checking Z_TYPE_P(val) == IS_RESOURCE. There is no need to call extended resource fetch functions though. Changed paths: M ext/openssl/openssl.c Diff: diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 98904cc..1cb6958 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1351,14 +1351,15 @@ static X509 * php_openssl_x509_from_zval(zval * val, int makeresource, zend_reso if (Z_TYPE_P(val) == IS_RESOURCE) { /* is it an x509 resource ? */ void * what; + zend_resource *res = Z_RES_P(val); - what = zend_fetch_resource_ex(val, "OpenSSL X.509", le_x509); + what = zend_fetch_resource(res, "OpenSSL X.509", le_x509); if (!what) { return NULL; } /* this is so callers can decide if they should free the X509 */ if (resourceval) { - *resourceval = Z_RES_P(val); + *resourceval = res; Z_ADDREF_P(val); } return (X509*)what; @@ -2762,11 +2763,12 @@ static X509_REQ * php_openssl_csr_from_zval(zval * val, int makeresource, zend_r } if (Z_TYPE_P(val) == IS_RESOURCE) { void * what; + zend_resource *res = Z_RES_P(val); - what = zend_fetch_resource_ex(val, "OpenSSL X.509 CSR", le_csr); + what = zend_fetch_resource(res, "OpenSSL X.509 CSR", le_csr); if (what) { if (resourceval) { - *resourceval = Z_RES_P(val); + *resourceval = res; Z_ADDREF_P(val); } return (X509_REQ*)what; @@ -3219,20 +3221,21 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval * val, int public_key, char * p if (Z_TYPE_P(val) == IS_RESOURCE) { void * what; + zend_resource * res = Z_RES_P(val); - what = zend_fetch_resource2_ex(val, "OpenSSL X.509/key", le_x509, le_key); + what = zend_fetch_resource2(res, "OpenSSL X.509/key", le_x509, le_key); if (!what) { TMP_CLEAN; } if (resourceval) { - *resourceval = Z_RES_P(val); + *resourceval = res; Z_ADDREF_P(val); } - if (Z_RES_P(val)->type == le_x509) { + if (res->type == le_x509) { /* extract key from cert, depending on public_key param */ cert = (X509*)what; free_cert = 0; - } else if (Z_RES_P(val)->type == le_key) { + } else if (res->type == le_key) { int is_priv; is_priv = php_openssl_is_private_key((EVP_PKEY*)what);

« previous php.cvs (#84968) next »