summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2015-02-02 13:23:16 +0800
committerXinchen Hui <laruence@gmail.com>2015-02-02 13:23:16 +0800
commit942809909e1bc125db038796c0a1a0b53eeaca7d (patch)
treebddec8b44878488fc73e8fe2fb9e30b7ee4f9b67 /ext
parentc9e44dc2dfa7ad91fe9253378a49e9f5b057992e (diff)
downloadphp-git-942809909e1bc125db038796c0a1a0b53eeaca7d.tar.gz
Cleanup resource handling APIs
Diffstat (limited to 'ext')
-rw-r--r--ext/curl/interface.c69
-rw-r--r--ext/curl/multi.c64
-rw-r--r--ext/curl/share.c11
-rw-r--r--ext/fileinfo/fileinfo.c15
-rw-r--r--ext/gd/gd.c373
-rw-r--r--ext/gd/gd_ctx.c4
-rw-r--r--ext/hash/hash.c25
-rw-r--r--ext/mysql/php_mysql.c162
-rw-r--r--ext/openssl/openssl.c53
-rw-r--r--ext/openssl/xp_ssl.c4
-rw-r--r--ext/shmop/shmop.c37
-rw-r--r--ext/soap/php_http.c4
-rw-r--r--ext/soap/soap.c14
-rw-r--r--ext/sockets/conversions.c8
-rw-r--r--ext/sockets/sendrecvmsg.c12
-rw-r--r--ext/sockets/sockets.c103
-rw-r--r--ext/standard/dir.c13
-rw-r--r--ext/standard/file.c2
-rw-r--r--ext/standard/proc_open.c14
-rw-r--r--ext/standard/streamsfuncs.c8
-rw-r--r--ext/standard/user_filters.c39
-rw-r--r--ext/sysvmsg/sysvmsg.c20
-rw-r--r--ext/sysvsem/sysvsem.c10
-rw-r--r--ext/sysvshm/sysvshm.c10
-rw-r--r--ext/xml/xml.c82
-rw-r--r--ext/xmlrpc/xmlrpc-epi-php.c32
-rw-r--r--ext/xmlwriter/php_xmlwriter.c85
-rw-r--r--ext/zip/php_zip.c34
28 files changed, 904 insertions, 403 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index dc9071f352..0b6711c8a9 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -230,7 +230,7 @@ void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
}
if (!Z_ISUNDEF(ch->handlers->std_err)) {
- stream = zend_fetch_resource(&ch->handlers->std_err, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
+ stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->std_err, NULL, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_STDERR resource has gone away, resetting to stderr");
@@ -242,7 +242,7 @@ void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
}
}
if (ch->handlers->read && !Z_ISUNDEF(ch->handlers->read->stream)) {
- stream = zend_fetch_resource(&ch->handlers->read->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
+ stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->read->stream, NULL, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_INFILE resource has gone away, resetting to default");
@@ -256,7 +256,7 @@ void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
}
}
if (ch->handlers->write_header && !Z_ISUNDEF(ch->handlers->write_header->stream)) {
- stream = zend_fetch_resource(&ch->handlers->write_header->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
+ stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->write_header->stream, NULL, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_WRITEHEADER resource has gone away, resetting to default");
@@ -270,7 +270,7 @@ void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
}
}
if (ch->handlers->write && !Z_ISUNDEF(ch->handlers->write->stream)) {
- stream = zend_fetch_resource(&ch->handlers->write->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
+ stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->write->stream, NULL, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_FILE resource has gone away, resetting to default");
@@ -1896,7 +1896,7 @@ PHP_FUNCTION(curl_init)
}
}
- ZEND_REGISTER_RESOURCE(return_value, ch, le_curl);
+ ZVAL_RES(return_value, zend_register_resource(ch, le_curl));
ch->res = Z_RES_P(return_value);
}
/* }}} */
@@ -1913,7 +1913,9 @@ PHP_FUNCTION(curl_copy_handle)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
cp = curl_easy_duphandle(ch->cp);
if (!cp) {
@@ -1994,7 +1996,7 @@ PHP_FUNCTION(curl_copy_handle)
/* Keep track of cloned copies to avoid invoking curl destructors for every clone */
ch->clone++;
- ZEND_REGISTER_RESOURCE(return_value, dupch, le_curl);
+ ZVAL_RES(return_value, zend_register_resource(dupch, le_curl));
dupch->res = Z_RES_P(return_value);
}
/* }}} */
@@ -2283,7 +2285,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
php_stream *what = NULL;
if (Z_TYPE_P(zvalue) != IS_NULL) {
- what = zend_fetch_resource(zvalue, -1, "File-Handle", &type, 1, php_file_le_stream(), php_file_le_pstream());
+ what = (php_stream *)zend_fetch_resource2_ex(zvalue, "File-Handle", &type, php_file_le_stream(), php_file_le_pstream());
if (!what) {
return FAILURE;
}
@@ -2719,9 +2721,8 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
case CURLOPT_SHARE:
{
- php_curlsh *sh = NULL;
- ZEND_FETCH_RESOURCE_NO_RETURN(sh, php_curlsh *, zvalue, -1, le_curl_share_handle_name, le_curl_share_handle);
- if (sh) {
+ php_curlsh *sh;
+ if ((sh = (php_curlsh *)zend_fetch_resource_ex(zvalue, le_curl_share_handle_name, le_curl_share_handle))) {
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
@@ -2765,7 +2766,9 @@ PHP_FUNCTION(curl_setopt)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
if (options <= 0 && options != CURLOPT_SAFE_UPLOAD) {
php_error_docref(NULL, E_WARNING, "Invalid curl configuration option");
@@ -2793,7 +2796,9 @@ PHP_FUNCTION(curl_setopt_array)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(arr), option, string_key, entry) {
if (string_key) {
@@ -2837,7 +2842,9 @@ PHP_FUNCTION(curl_exec)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
_php_curl_verify_handlers(ch, 1);
@@ -2853,7 +2860,7 @@ PHP_FUNCTION(curl_exec)
if (!Z_ISUNDEF(ch->handlers->std_err)) {
php_stream *stream;
- stream = zend_fetch_resource(&ch->handlers->std_err, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
+ stream = (php_stream*)zend_fetch_resource2_ex(&ch->handlers->std_err, NULL, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream) {
php_stream_flush(stream);
}
@@ -2892,7 +2899,9 @@ PHP_FUNCTION(curl_getinfo)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
if (ZEND_NUM_ARGS() < 2) {
char *s_code;
@@ -3097,7 +3106,9 @@ PHP_FUNCTION(curl_error)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
ch->err.str[CURL_ERROR_SIZE] = 0;
RETURN_STRING(ch->err.str);
@@ -3115,7 +3126,9 @@ PHP_FUNCTION(curl_errno)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(ch->err.no);
}
@@ -3132,7 +3145,9 @@ PHP_FUNCTION(curl_close)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
if (ch->in_callback) {
php_error_docref(NULL, E_WARNING, "Attempt to close cURL handle from a callback");
@@ -3308,7 +3323,9 @@ PHP_FUNCTION(curl_reset)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
if (ch->in_callback) {
php_error_docref(NULL, E_WARNING, "Attempt to reset cURL handle from a callback");
@@ -3336,7 +3353,9 @@ PHP_FUNCTION(curl_escape)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
if ((res = curl_easy_escape(ch->cp, str, str_len))) {
RETVAL_STRING(res);
@@ -3361,7 +3380,9 @@ PHP_FUNCTION(curl_unescape)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
if ((out = curl_easy_unescape(ch->cp, str, str_len, &out_len))) {
RETVAL_STRINGL(out, out_len);
@@ -3386,7 +3407,9 @@ PHP_FUNCTION(curl_pause)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(curl_easy_pause(ch->cp, bitmask));
}
diff --git a/ext/curl/multi.c b/ext/curl/multi.c
index e3db38b207..0cd4ae2761 100644
--- a/ext/curl/multi.c
+++ b/ext/curl/multi.c
@@ -64,7 +64,7 @@ PHP_FUNCTION(curl_multi_init)
zend_llist_init(&mh->easyh, sizeof(zval), _php_curl_multi_cleanup_list, 0);
- ZEND_REGISTER_RESOURCE(return_value, mh, le_curl_multi_handle);
+ RETURN_RES(zend_register_resource(mh, le_curl_multi_handle));
}
/* }}} */
@@ -82,8 +82,13 @@ PHP_FUNCTION(curl_multi_add_handle)
return;
}
- ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
- ZEND_FETCH_RESOURCE(ch, php_curl *, z_ch, -1, le_curl_name, le_curl);
+ if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(z_ch), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
_php_curl_cleanup_handle(ch);
@@ -104,13 +109,10 @@ void _php_curl_multi_cleanup_list(void *data) /* {{{ */
if (!z_ch) {
return;
}
-
- if (Z_RES_P(z_ch)->ptr == NULL) {
+ if (!Z_RES_P(z_ch)->ptr) {
return;
}
-
- ch = zend_fetch_resource(z_ch, -1, le_curl_name, NULL, 1, le_curl);
- if (!ch) {
+ if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(z_ch), le_curl_name, le_curl)) == NULL) {
return;
}
@@ -140,8 +142,13 @@ PHP_FUNCTION(curl_multi_remove_handle)
return;
}
- ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
- ZEND_FETCH_RESOURCE(ch, php_curl *, z_ch, -1, le_curl_name, le_curl);
+ if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(z_ch), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
RETVAL_LONG((zend_long)curl_multi_remove_handle(mh->multi, ch->cp));
zend_llist_del_element(&mh->easyh, &z_ch, (int (*)(void *, void *))curl_compare_resources);
@@ -176,7 +183,9 @@ PHP_FUNCTION(curl_multi_select)
return;
}
- ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
+ if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
+ RETURN_FALSE;
+ }
_make_timeval_struct(&to, timeout);
@@ -206,17 +215,22 @@ PHP_FUNCTION(curl_multi_exec)
return;
}
- ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
+ if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
+ RETURN_FALSE;
+ }
{
zend_llist_position pos;
php_curl *ch;
zval *pz_ch;
- for(pz_ch = (zval *)zend_llist_get_first_ex(&mh->easyh, &pos); pz_ch;
+ for (pz_ch = (zval *)zend_llist_get_first_ex(&mh->easyh, &pos); pz_ch;
pz_ch = (zval *)zend_llist_get_next_ex(&mh->easyh, &pos)) {
- ZEND_FETCH_RESOURCE(ch, php_curl *, pz_ch, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(pz_ch), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
+
_php_curl_verify_handlers(ch, 1);
}
}
@@ -241,7 +255,9 @@ PHP_FUNCTION(curl_multi_getcontent)
return;
}
- ZEND_FETCH_RESOURCE(ch, php_curl *, z_ch, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(z_ch), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
if (ch->handlers->write->method == PHP_CURL_RETURN) {
if (!ch->handlers->write->buf.s) {
@@ -269,7 +285,9 @@ PHP_FUNCTION(curl_multi_info_read)
return;
}
- ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
+ if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
+ RETURN_FALSE;
+ }
tmp_msg = curl_multi_info_read(mh->multi, &queued_msgs);
if (tmp_msg == NULL) {
@@ -294,7 +312,9 @@ PHP_FUNCTION(curl_multi_info_read)
for(pz_ch = (zval *)zend_llist_get_first_ex(&mh->easyh, &pos); pz_ch;
pz_ch = (zval *)zend_llist_get_next_ex(&mh->easyh, &pos)) {
- ZEND_FETCH_RESOURCE(ch, php_curl *, pz_ch, -1, le_curl_name, le_curl);
+ if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(pz_ch), le_curl_name, le_curl)) == NULL) {
+ RETURN_FALSE;
+ }
if (ch->cp == tmp_msg->easy_handle) {
/* we are adding a reference to the underlying php_curl
@@ -329,7 +349,9 @@ PHP_FUNCTION(curl_multi_close)
return;
}
- ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
+ if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
+ RETURN_FALSE;
+ }
zend_list_close(Z_RES_P(z_mh));
}
@@ -347,7 +369,7 @@ void _php_curl_multi_close(zend_resource *rsrc) /* {{{ */
pz_ch = (zval *)zend_llist_get_next_ex(&mh->easyh, &pos)) {
/* ptr is NULL means it already be freed */
if (Z_RES_P(pz_ch)->ptr) {
- ch = (php_curl *) zend_fetch_resource(pz_ch, -1, le_curl_name, NULL, 1, le_curl);
+ ch = (php_curl *) zend_fetch_resource(Z_RES_P(pz_ch), le_curl_name, le_curl);
_php_curl_verify_handlers(ch, 0);
}
}
@@ -424,7 +446,9 @@ PHP_FUNCTION(curl_multi_setopt)
return;
}
- ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
+ if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
+ RETURN_FALSE;
+ }
if (!_php_curl_multi_setopt(mh, options, zvalue, return_value)) {
RETURN_TRUE;
diff --git a/ext/curl/share.c b/ext/curl/share.c
index 5fc64d0085..294b475b31 100644
--- a/ext/curl/share.c
+++ b/ext/curl/share.c
@@ -46,7 +46,7 @@ PHP_FUNCTION(curl_share_init)
sh->share = curl_share_init();
- ZEND_REGISTER_RESOURCE(return_value, sh, le_curl_share_handle);
+ RETURN_RES(zend_register_resource(sh, le_curl_share_handle));
}
/* }}} */
@@ -61,7 +61,10 @@ PHP_FUNCTION(curl_share_close)
return;
}
- ZEND_FETCH_RESOURCE(sh, php_curlsh *, z_sh, -1, le_curl_share_handle_name, le_curl_share_handle);
+ if ((sh = (php_curlsh *)zend_fetch_resource(Z_RES_P(z_sh), le_curl_share_handle_name, le_curl_share_handle)) == NULL) {
+ RETURN_FALSE;
+ }
+
zend_list_close(Z_RES_P(z_sh));
}
/* }}} */
@@ -103,7 +106,9 @@ PHP_FUNCTION(curl_share_setopt)
return;
}
- ZEND_FETCH_RESOURCE(sh, php_curlsh *, zid, -1, le_curl_share_handle_name, le_curl_share_handle);
+ if ((sh = (php_curlsh *)zend_fetch_resource(Z_RES_P(zid), le_curl_share_handle_name, le_curl_share_handle)) == NULL) {
+ RETURN_FALSE;
+ }
if (!_php_curl_share_setopt(sh, options, zvalue, return_value)) {
RETURN_TRUE;
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
index 7d64b24549..f9eebd0484 100644
--- a/ext/fileinfo/fileinfo.c
+++ b/ext/fileinfo/fileinfo.c
@@ -355,7 +355,7 @@ PHP_FUNCTION(finfo_open)
if (object) {
FILEINFO_REGISTER_OBJECT(object, finfo);
} else {
- ZEND_REGISTER_RESOURCE(return_value, finfo, le_fileinfo);
+ RETURN_RES(zend_register_resource(finfo, le_fileinfo));
}
}
/* }}} */
@@ -370,7 +370,10 @@ PHP_FUNCTION(finfo_close)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zfinfo) == FAILURE) {
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(finfo, php_fileinfo *, zfinfo, -1, "file_info", le_fileinfo);
+
+ if ((finfo = (php_fileinfo *)zend_fetch_resource(Z_RES_P(zfinfo), "file_info", le_fileinfo)) == NULL) {
+ RETURN_FALSE;
+ }
zend_list_close(Z_RES_P(zfinfo));
@@ -396,7 +399,9 @@ PHP_FUNCTION(finfo_set_flags)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &zfinfo, &options) == FAILURE) {
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(finfo, php_fileinfo *, zfinfo, -1, "file_info", le_fileinfo);
+ if ((finfo = (php_fileinfo *)zend_fetch_resource(Z_RES_P(zfinfo), "file_info", le_fileinfo)) == NULL) {
+ RETURN_FALSE;
+ }
}
FINFO_SET_OPTION(finfo->magic, options)
@@ -461,7 +466,9 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|lr", &zfinfo, &buffer, &buffer_len, &options, &zcontext) == FAILURE) {
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(finfo, php_fileinfo *, zfinfo, -1, "file_info", le_fileinfo);
+ if ((finfo = (php_fileinfo *)zend_fetch_resource(Z_RES_P(zfinfo), "file_info", le_fileinfo)) == NULL) {
+ RETURN_FALSE;
+ }
magic = finfo->magic;
}
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index a928c8ecf9..3783fe82b2 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -1538,7 +1538,9 @@ PHP_FUNCTION(imagesetstyle)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
/* copy the style values in the stylearr */
stylearr = safe_emalloc(sizeof(int), zend_hash_num_elements(HASH_OF(styles)), 0);
@@ -1577,7 +1579,7 @@ PHP_FUNCTION(imagecreatetruecolor)
RETURN_FALSE;
}
- ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
+ RETURN_RES(zend_register_resource(im, le_gd));
}
/* }}} */
@@ -1592,7 +1594,9 @@ PHP_FUNCTION(imageistruecolor)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_BOOL(im->trueColor);
}
@@ -1611,7 +1615,9 @@ PHP_FUNCTION(imagetruecolortopalette)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (ncolors <= 0) {
php_error_docref(NULL, E_WARNING, "Number of colors has to be greater than zero");
@@ -1634,7 +1640,9 @@ PHP_FUNCTION(imagepalettetotruecolor)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (gdImagePaletteToTrueColor(im) == 0) {
RETURN_FALSE;
@@ -1656,8 +1664,12 @@ PHP_FUNCTION(imagecolormatch)
return;
}
- ZEND_FETCH_RESOURCE(im1, gdImagePtr, IM1, -1, "Image", le_gd);
- ZEND_FETCH_RESOURCE(im2, gdImagePtr, IM2, -1, "Image", le_gd);
+ if ((im1 = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM1), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+ if ((im2 = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM2), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
result = gdImageColorMatch(im1, im2);
switch (result) {
@@ -1695,7 +1707,9 @@ PHP_FUNCTION(imagesetthickness)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
gdImageSetThickness(im, thick);
@@ -1715,7 +1729,9 @@ PHP_FUNCTION(imagefilledellipse)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
gdImageFilledEllipse(im, cx, cy, w, h, color);
@@ -1736,7 +1752,9 @@ PHP_FUNCTION(imagefilledarc)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
e = E;
if (e < 0) {
@@ -1766,7 +1784,10 @@ PHP_FUNCTION(imagealphablending)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
gdImageAlphaBlending(im, blend);
RETURN_TRUE;
@@ -1785,7 +1806,10 @@ PHP_FUNCTION(imagesavealpha)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
gdImageSaveAlpha(im, save);
RETURN_TRUE;
@@ -1804,7 +1828,10 @@ PHP_FUNCTION(imagelayereffect)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
gdImageAlphaBlending(im, effect);
RETURN_TRUE;
@@ -1824,7 +1851,10 @@ PHP_FUNCTION(imagecolorallocatealpha)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
ct = gdImageColorAllocateAlpha(im, red, green, blue, alpha);
if (ct < 0) {
RETURN_FALSE;
@@ -1845,7 +1875,9 @@ PHP_FUNCTION(imagecolorresolvealpha)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(gdImageColorResolveAlpha(im, red, green, blue, alpha));
}
@@ -1863,7 +1895,9 @@ PHP_FUNCTION(imagecolorclosestalpha)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(gdImageColorClosestAlpha(im, red, green, blue, alpha));
}
@@ -1881,7 +1915,9 @@ PHP_FUNCTION(imagecolorexactalpha)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(gdImageColorExactAlpha(im, red, green, blue, alpha));
}
@@ -1900,8 +1936,13 @@ PHP_FUNCTION(imagecopyresampled)
return;
}
- ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd);
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
+ if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
srcX = SX;
srcY = SY;
@@ -2003,7 +2044,7 @@ clean:
if (!im) {
RETURN_FALSE;
} else {
- ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
+ RETURN_RES(zend_register_resource(im, le_gd));
}
}
/* }}} */
@@ -2062,7 +2103,7 @@ PHP_FUNCTION(imagegrabscreen)
if (!im) {
RETURN_FALSE;
} else {
- ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
+ RETURN_RES(zend_register_resource(im, le_gd));
}
}
/* }}} */
@@ -2082,12 +2123,14 @@ PHP_FUNCTION(imagerotate)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
im_dst = gdImageRotateInterpolated(im_src, (const float)degrees, color);
if (im_dst != NULL) {
- ZEND_REGISTER_RESOURCE(return_value, im_dst, le_gd);
+ RETURN_RES(zend_register_resource(im_dst, le_gd));
} else {
RETURN_FALSE;
}
@@ -2105,8 +2148,13 @@ PHP_FUNCTION(imagesettile)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
- ZEND_FETCH_RESOURCE(tile, gdImagePtr, TILE, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((tile = (gdImagePtr)zend_fetch_resource(Z_RES_P(TILE), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
gdImageSetTile(im, tile);
@@ -2125,8 +2173,13 @@ PHP_FUNCTION(imagesetbrush)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
- ZEND_FETCH_RESOURCE(tile, gdImagePtr, TILE, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((tile = (gdImagePtr)zend_fetch_resource(Z_RES_P(TILE), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
gdImageSetBrush(im, tile);
@@ -2156,7 +2209,7 @@ PHP_FUNCTION(imagecreate)
RETURN_FALSE;
}
- ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
+ RETURN_RES(zend_register_resource(im, le_gd));
}
/* }}} */
@@ -2333,7 +2386,7 @@ PHP_FUNCTION(imagecreatefromstring)
RETURN_FALSE;
}
- ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
+ RETURN_RES(zend_register_resource(im, le_gd));
}
/* }}} */
@@ -2443,7 +2496,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
/* register_im: */
if (im) {
- ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
+ RETVAL_RES(zend_register_resource(im, le_gd));
php_stream_close(stream);
return;
}
@@ -2566,7 +2619,9 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(imgind), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (argc > 1) {
fn = file;
@@ -2780,7 +2835,9 @@ PHP_FUNCTION(imagedestroy)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
zend_list_close(Z_RES_P(IM));
@@ -2802,7 +2859,9 @@ PHP_FUNCTION(imagecolorallocate)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
ct = gdImageColorAllocate(im, red, green, blue);
if (ct < 0) {
@@ -2823,8 +2882,13 @@ PHP_FUNCTION(imagepalettecopy)
return;
}
- ZEND_FETCH_RESOURCE(dst, gdImagePtr, dstim, -1, "Image", le_gd);
- ZEND_FETCH_RESOURCE(src, gdImagePtr, srcim, -1, "Image", le_gd);
+ if ((dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(dstim), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((src = (gdImagePtr)zend_fetch_resource(Z_RES_P(srcim), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
gdImagePaletteCopy(dst, src);
}
@@ -2842,7 +2906,9 @@ PHP_FUNCTION(imagecolorat)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (gdImageTrueColor(im)) {
if (im->tpixels && gdImageBoundsSafe(im, x, y)) {
@@ -2874,7 +2940,9 @@ PHP_FUNCTION(imagecolorclosest)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(gdImageColorClosest(im, red, green, blue));
}
@@ -2892,7 +2960,9 @@ PHP_FUNCTION(imagecolorclosesthwb)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(gdImageColorClosestHWB(im, red, green, blue));
}
@@ -2911,7 +2981,9 @@ PHP_FUNCTION(imagecolordeallocate)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
/* We can return right away for a truecolor image as deallocating colours is meaningless here */
if (gdImageTrueColor(im)) {
@@ -2942,7 +3014,9 @@ PHP_FUNCTION(imagecolorresolve)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(gdImageColorResolve(im, red, green, blue));
}
@@ -2960,7 +3034,9 @@ PHP_FUNCTION(imagecolorexact)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(gdImageColorExact(im, red, green, blue));
}
@@ -2979,7 +3055,9 @@ PHP_FUNCTION(imagecolorset)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
col = color;
@@ -3007,7 +3085,9 @@ PHP_FUNCTION(imagecolorsforindex)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
col = index;
@@ -3038,7 +3118,9 @@ PHP_FUNCTION(imagegammacorrect)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (gdImageTrueColor(im)) {
int x, y, c;
@@ -3080,7 +3162,10 @@ PHP_FUNCTION(imagesetpixel)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
gdImageSetPixel(im, x, y, col);
RETURN_TRUE;
}
@@ -3098,7 +3183,9 @@ PHP_FUNCTION(imageline)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
#ifdef HAVE_GD_BUNDLED
if (im->antialias) {
@@ -3124,7 +3211,10 @@ PHP_FUNCTION(imagedashedline)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
gdImageDashedLine(im, x1, y1, x2, y2, col);
RETURN_TRUE;
}
@@ -3142,7 +3232,10 @@ PHP_FUNCTION(imagerectangle)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
gdImageRectangle(im, x1, y1, x2, y2, col);
RETURN_TRUE;
}
@@ -3160,7 +3253,9 @@ PHP_FUNCTION(imagefilledrectangle)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
gdImageFilledRectangle(im, x1, y1, x2, y2, col);
RETURN_TRUE;
}
@@ -3179,7 +3274,9 @@ PHP_FUNCTION(imagearc)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
e = E;
if (e < 0) {
@@ -3208,7 +3305,9 @@ PHP_FUNCTION(imageellipse)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
gdImageEllipse(im, cx, cy, w, h, color);
RETURN_TRUE;
@@ -3227,7 +3326,10 @@ PHP_FUNCTION(imagefilltoborder)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
gdImageFillToBorder(im, x, y, border, col);
RETURN_TRUE;
}
@@ -3245,7 +3347,10 @@ PHP_FUNCTION(imagefill)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
gdImageFill(im, x, y, col);
RETURN_TRUE;
}
@@ -3262,7 +3367,9 @@ PHP_FUNCTION(imagecolorstotal)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(gdImageColorsTotal(im));
}
@@ -3281,7 +3388,9 @@ PHP_FUNCTION(imagecolortransparent)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (argc > 1) {
gdImageColorTransparent(im, COL);
@@ -3304,7 +3413,9 @@ PHP_FUNCTION(imageinterlace)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (argc > 1) {
gdImageInterlace(im, INT);
@@ -3331,7 +3442,9 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
npoints = NPOINTS;
col = COL;
@@ -3510,7 +3623,9 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
col = COL;
@@ -3601,8 +3716,13 @@ PHP_FUNCTION(imagecopy)
return;
}
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
- ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd);
+ if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
srcX = SX;
srcY = SY;
@@ -3629,8 +3749,13 @@ PHP_FUNCTION(imagecopymerge)
return;
}
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
- ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd);
+ if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
srcX = SX;
srcY = SY;
@@ -3658,8 +3783,13 @@ PHP_FUNCTION(imagecopymergegray)
return;
}
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
- ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd);
+ if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
srcX = SX;
srcY = SY;
@@ -3687,8 +3817,13 @@ PHP_FUNCTION(imagecopyresized)
return;
}
- ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd);
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
+ if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
srcX = SX;
srcY = SY;
@@ -3720,7 +3855,9 @@ PHP_FUNCTION(imagesx)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(gdImageSX(im));
}
@@ -3737,7 +3874,9 @@ PHP_FUNCTION(imagesy)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(gdImageSY(im));
}
@@ -3811,7 +3950,9 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
} else if (zend_parse_parameters(argc, "rddlllss|a", &IM, &ptsize, &angle, &x, &y, &col, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) {
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
}
/* convert angle to radians */
@@ -3928,7 +4069,7 @@ PHP_FUNCTION(imagepsloadfont)
font = (int *) emalloc(sizeof(int));
*font = f_ind;
- ZEND_REGISTER_RESOURCE(return_value, font, le_ps_font);
+ RETURN_RES(zend_register_resource(font, le_gd));
}
/* }}} */
@@ -3996,7 +4137,10 @@ PHP_FUNCTION(imagepsfreefont)
return;
}
- ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
+ if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
+ RETURN_FALSE;
+ }
+
zend_list_close(Z_RES_P(fnt));
RETURN_TRUE;
}
@@ -4015,7 +4159,9 @@ PHP_FUNCTION(imagepsencodefont)
return;
}
- ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
+ if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
+ RETURN_FALSE;
+ }
if ((enc_vector = T1_LoadEncoding(enc)) == NULL) {
php_error_docref(NULL, E_WARNING, "Couldn't load encoding vector from %s", enc);
@@ -4047,7 +4193,9 @@ PHP_FUNCTION(imagepsextendfont)
return;
}
- ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
+ if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
+ RETURN_FALSE;
+ }
T1_DeleteAllSizes(*f_ind);
@@ -4076,7 +4224,9 @@ PHP_FUNCTION(imagepsslantfont)
return;
}
- ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
+ if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
+ RETURN_FALSE;
+ }
if (T1_SlantFont(*f_ind, slt) != 0) {
RETURN_FALSE;
@@ -4116,8 +4266,12 @@ PHP_FUNCTION(imagepstext)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(bg_img, gdImagePtr, img, -1, "Image", le_gd);
- ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
+ if ((bg_img = (gdImagePtr)zend_fetch_resource(Z_RES_P(img), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
+ if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
+ RETURN_FALSE;
+ }
/* Ensure that the provided colors are valid */
if (_fg < 0 || (!gdImageTrueColor(bg_img) && _fg > gdImageColorsTotal(bg_img))) {
@@ -4257,7 +4411,9 @@ PHP_FUNCTION(imagepsbbox)
per_char = add_width || angle ? 1 : 0;
}
- ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
+ if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
+ RETURN_FALSE;
+ }
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
@@ -4589,8 +4745,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
if (zend_parse_parameters(1, "r", &SIM) == FAILURE) { \
RETURN_FALSE; \
} \
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd); \
- if (im_src == NULL) { \
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { \
RETURN_FALSE; \
}
@@ -4626,7 +4781,9 @@ static void php_image_filter_brightness(INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (im_src == NULL) {
RETURN_FALSE;
@@ -4649,7 +4806,9 @@ static void php_image_filter_contrast(INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (im_src == NULL) {
RETURN_FALSE;
@@ -4673,7 +4832,9 @@ static void php_image_filter_colorize(INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (im_src == NULL) {
RETURN_FALSE;
@@ -4752,7 +4913,9 @@ static void php_image_filter_smooth(INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (im_src == NULL) {
RETURN_FALSE;
@@ -4776,7 +4939,9 @@ static void php_image_filter_pixelate(INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (im == NULL) {
RETURN_FALSE;
@@ -4840,7 +5005,9 @@ PHP_FUNCTION(imageconvolution)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
+ if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
nelem = zend_hash_num_elements(Z_ARRVAL_P(hash_matrix));
if (nelem != 3) {
@@ -4888,7 +5055,9 @@ PHP_FUNCTION(imageflip)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
switch (mode) {
case GD_FLIP_VERTICAL:
@@ -4925,7 +5094,9 @@ PHP_FUNCTION(imageantialias)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
gdImageAntialias(im, alias);
RETURN_TRUE;
}
@@ -4947,7 +5118,9 @@ PHP_FUNCTION(imagecrop)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if ((tmp = zend_hash_str_find(HASH_OF(z_rect), "x", sizeof("x") -1)) != NULL) {
rect.x = zval_get_long(tmp);
@@ -4982,7 +5155,7 @@ PHP_FUNCTION(imagecrop)
if (im_crop == NULL) {
RETURN_FALSE;
} else {
- ZEND_REGISTER_RESOURCE(return_value, im_crop, le_gd);
+ RETURN_RES(zend_register_resource(im_crop, le_gd));
}
}
/* }}} */
@@ -5002,7 +5175,9 @@ PHP_FUNCTION(imagecropauto)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
switch (mode) {
case -1:
@@ -5030,7 +5205,7 @@ PHP_FUNCTION(imagecropauto)
if (im_crop == NULL) {
RETURN_FALSE;
} else {
- ZEND_REGISTER_RESOURCE(return_value, im_crop, le_gd);
+ RETURN_RES(zend_register_resource(im_crop, le_gd));
}
}
/* }}} */
@@ -5051,7 +5226,9 @@ PHP_FUNCTION(imagescale)
}
method = tmp_m;
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (tmp_h < 0) {
/* preserve ratio */
@@ -5074,7 +5251,7 @@ PHP_FUNCTION(imagescale)
if (im_scaled == NULL) {
RETURN_FALSE;
} else {
- ZEND_REGISTER_RESOURCE(return_value, im_scaled, le_gd);
+ RETURN_RES(zend_register_resource(im_scaled, le_gd));
}
}
/* }}} */
@@ -5099,7 +5276,9 @@ PHP_FUNCTION(imageaffine)
return;
}
- ZEND_FETCH_RESOURCE(src, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((src = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if ((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_affine))) != 6) {
php_error_docref(NULL, E_WARNING, "Affine array must have six elements");
@@ -5169,7 +5348,7 @@ PHP_FUNCTION(imageaffine)
if (dst == NULL) {
RETURN_FALSE;
} else {
- ZEND_REGISTER_RESOURCE(return_value, dst, le_gd);
+ RETURN_RES(zend_register_resource(dst, le_gd));
}
}
/* }}} */
@@ -5334,7 +5513,9 @@ PHP_FUNCTION(imagesetinterpolation)
return;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
+ RETURN_FALSE;
+ }
if (method == -1) {
method = GD_BILINEAR_FIXED;
diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c
index 028a37e435..c848e438c7 100644
--- a/ext/gd/gd_ctx.c
+++ b/ext/gd/gd_ctx.c
@@ -103,7 +103,9 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
}
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", phpi_get_le_gd());
+ if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(imgind), "Image", phpi_get_le_gd())) == NULL) {
+ RETURN_FALSE;
+ }
if (argc >= 3) {
q = quality; /* or colorindex for foreground of BW images (defaults to black) */
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index 555934dc30..4c4f96fc89 100644
--- a/ext/hash/hash.c
+++ b/ext/hash/hash.c
@@ -386,7 +386,7 @@ PHP_FUNCTION(hash_init)
hash->key = (unsigned char *) K;
}
- ZEND_REGISTER_RESOURCE(return_value, hash, php_hash_le_hash);
+ RETURN_RES(zend_register_resource(hash, php_hash_le_hash));
}
/* }}} */
@@ -403,7 +403,9 @@ PHP_FUNCTION(hash_update)
return;
}
- ZEND_FETCH_RESOURCE(hash, php_hash_data*, zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
+ if ((hash = (php_hash_data *)zend_fetch_resource(Z_RES_P(zhash), PHP_HASH_RESNAME, php_hash_le_hash)) == NULL) {
+ RETURN_FALSE;
+ }
hash->ops->hash_update(hash->context, (unsigned char *) data, data_len);
@@ -424,7 +426,10 @@ PHP_FUNCTION(hash_update_stream)
return;
}
- ZEND_FETCH_RESOURCE(hash, php_hash_data*, zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
+ if ((hash = (php_hash_data *)zend_fetch_resource(Z_RES_P(zhash), PHP_HASH_RESNAME, php_hash_le_hash)) == NULL) {
+ RETURN_FALSE;
+ }
+
php_stream_from_zval(stream, zstream);
while (length) {
@@ -463,7 +468,9 @@ PHP_FUNCTION(hash_update_file)
return;
}
- ZEND_FETCH_RESOURCE(hash, php_hash_data*, zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
+ if ((hash = (php_hash_data *)zend_fetch_resource(Z_RES_P(zhash), PHP_HASH_RESNAME, php_hash_le_hash)) == NULL) {
+ RETURN_FALSE;
+ }
context = php_stream_context_from_zval(zcontext, 0);
stream = php_stream_open_wrapper_ex(filename, "rb", REPORT_ERRORS, NULL, context);
@@ -495,7 +502,9 @@ PHP_FUNCTION(hash_final)
return;
}
- ZEND_FETCH_RESOURCE(hash, php_hash_data*, zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
+ if ((hash = (php_hash_data *)zend_fetch_resource(Z_RES_P(zhash), PHP_HASH_RESNAME, php_hash_le_hash)) == NULL) {
+ RETURN_FALSE;
+ }
digest_len = hash->ops->digest_size;
digest = zend_string_alloc(digest_len, 0);
@@ -558,7 +567,9 @@ PHP_FUNCTION(hash_copy)
return;
}
- ZEND_FETCH_RESOURCE(hash, php_hash_data*, zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
+ if ((hash = (php_hash_data *)zend_fetch_resource(Z_RES_P(zhash), PHP_HASH_RESNAME, php_hash_le_hash)) == NULL) {
+ RETURN_FALSE;
+ }
context = emalloc(hash->ops->context_size);
@@ -578,7 +589,7 @@ PHP_FUNCTION(hash_copy)
if (hash->key) {
memcpy(copy_hash->key, hash->key, hash->ops->block_size);
}
- ZEND_REGISTER_RESOURCE(return_value, copy_hash, php_hash_le_hash);
+ RETURN_RES(zend_register_resource(copy_hash, php_hash_le_hash));
}
/* }}} */
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 2af92963f8..6495c1ec4c 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -543,9 +543,7 @@ static MYSQLND *mysql_convert_zv_to_mysqlnd(zval *zv)
return NULL;
}
- mysql = zend_fetch_resource(zv, -1, "MySQL-Link", NULL, 2, le_link, le_plink);
-
- if (!mysql) {
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(zv), "MySQL-Link", NULL, le_link, le_plink))) {
return NULL;
}
@@ -966,7 +964,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
#endif
}
}
- ZEND_REGISTER_RESOURCE(return_value, mysql, le_plink);
+ ZVAL_RES(return_value, zend_register_resource(mysql, le_plink));
} else { /* non persistent */
zend_resource *index_ptr;
zval new_index_ptr;
@@ -1051,7 +1049,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
mysql_options(mysql->conn, MYSQL_OPT_LOCAL_INFILE, (char *)&MySG(allow_local_infile));
/* add it to the list */
- ZEND_REGISTER_RESOURCE(return_value, mysql, le_link);
+ ZVAL_RES(return_value, zend_register_resource(mysql, le_link));
/* add it to the hash */
ZVAL_NEW_RES(&new_index_ptr, -1, Z_RES_P(return_value), le_index_ptr);
@@ -1111,9 +1109,13 @@ PHP_FUNCTION(mysql_close)
}
if (mysql_link) {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, NULL, MySG(default_link)? MySG(default_link)->handle : -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(MySG(default_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
res = mysql_link ? Z_RES_P(mysql_link) : MySG(default_link);
@@ -1158,7 +1160,9 @@ PHP_FUNCTION(mysql_select_db)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
if (php_mysql_select_db(mysql, db)) {
@@ -1199,7 +1203,9 @@ PHP_FUNCTION(mysql_get_host_info)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
RETURN_STRING((char *)mysql_get_host_info(mysql->conn));
@@ -1222,7 +1228,9 @@ PHP_FUNCTION(mysql_get_proto_info)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
RETURN_LONG(mysql_get_proto_info(mysql->conn));
@@ -1245,7 +1253,9 @@ PHP_FUNCTION(mysql_get_server_info)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
RETURN_STRING((char *)mysql_get_server_info(mysql->conn));
@@ -1269,7 +1279,9 @@ PHP_FUNCTION(mysql_info)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
if ((str = (char *)mysql_info(mysql->conn))) {
@@ -1296,7 +1308,9 @@ PHP_FUNCTION(mysql_thread_id)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
RETURN_LONG((zend_long) mysql_thread_id(mysql->conn));
@@ -1325,7 +1339,9 @@ PHP_FUNCTION(mysql_stat)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
PHPMY_UNBUFFERED_QUERY_CHECK();
@@ -1358,7 +1374,9 @@ PHP_FUNCTION(mysql_client_encoding)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
RETURN_STRING((char *)mysql_character_set_name(mysql->conn));
@@ -1385,7 +1403,9 @@ PHP_FUNCTION(mysql_set_charset)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
if (!mysql_set_character_set(mysql->conn, csname)) {
@@ -1417,7 +1437,9 @@ PHP_FUNCTION(mysql_create_db)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
PHPMY_UNBUFFERED_QUERY_CHECK();
@@ -1448,10 +1470,12 @@ PHP_FUNCTION(mysql_drop_db)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
- if (mysql_drop_db(mysql->conn, db)==0) {
+ if (mysql_drop_db(mysql->conn, db) == 0) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1542,7 +1566,8 @@ static void php_mysql_do_query_general(php_mysql_conn *mysql, char *query, int q
}
}
MySG(result_allocated)++;
- ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
+ ZVAL_RES(return_value, zend_register_resource(mysql_result, le_result));
+
if (use_store == MYSQL_USE_RESULT) {
mysql->active_result_res = Z_RES_P(return_value);
Z_ADDREF_P(return_value);
@@ -1568,7 +1593,9 @@ static void php_mysql_do_query(INTERNAL_FUNCTION_PARAMETERS, int use_store)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
php_mysql_do_query_general(mysql, query, query_len, NULL, use_store, return_value);
@@ -1609,7 +1636,9 @@ PHP_FUNCTION(mysql_db_query)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
php_error_docref(NULL, E_DEPRECATED, "This function is deprecated; use mysql_query() instead");
@@ -1635,7 +1664,9 @@ PHP_FUNCTION(mysql_list_dbs)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
php_error_docref(NULL, E_DEPRECATED, "This function is deprecated; use mysql_query() with SHOW DATABASES instead");
@@ -1648,7 +1679,7 @@ PHP_FUNCTION(mysql_list_dbs)
}
MySG(result_allocated)++;
- ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
+ ZVAL_RES(return_value, zend_register_resource(mysql_result, le_result));
}
/* }}} */
@@ -1671,7 +1702,9 @@ PHP_FUNCTION(mysql_list_tables)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
if (!php_mysql_select_db(mysql, db)) {
@@ -1685,7 +1718,7 @@ PHP_FUNCTION(mysql_list_tables)
RETURN_FALSE;
}
MySG(result_allocated)++;
- ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
+ ZVAL_RES(return_value, zend_register_resource(mysql_result, le_result));
}
/* }}} */
@@ -1708,7 +1741,9 @@ PHP_FUNCTION(mysql_list_fields)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
if (!php_mysql_select_db(mysql, db)) {
@@ -1722,7 +1757,7 @@ PHP_FUNCTION(mysql_list_fields)
RETURN_FALSE;
}
MySG(result_allocated)++;
- ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
+ ZVAL_RES(return_value, zend_register_resource(mysql_result, le_result));
}
/* }}} */
@@ -1743,7 +1778,9 @@ PHP_FUNCTION(mysql_list_processes)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
PHPMY_UNBUFFERED_QUERY_CHECK();
@@ -1755,7 +1792,7 @@ PHP_FUNCTION(mysql_list_processes)
}
MySG(result_allocated)++;
- ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
+ ZVAL_RES(return_value, zend_register_resource(mysql_result, le_result));
}
/* }}} */
@@ -1780,7 +1817,9 @@ PHP_FUNCTION(mysql_error)
}
mysql = (php_mysql_conn*)MySG(default_link)->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
RETURN_STRING((char *)mysql_error(mysql->conn));
@@ -1809,7 +1848,9 @@ PHP_FUNCTION(mysql_errno)
}
mysql = (php_mysql_conn*)MySG(default_link)->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
RETURN_LONG(mysql_errno(mysql->conn));
@@ -1833,7 +1874,9 @@ PHP_FUNCTION(mysql_affected_rows)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
/* conversion from int64 to long happing here */
@@ -1884,7 +1927,9 @@ PHP_FUNCTION(mysql_real_escape_string)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
/* assume worst case situation, which is 2x of the original string.
@@ -1914,7 +1959,9 @@ PHP_FUNCTION(mysql_insert_id)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
/* conversion from int64 to long happing here */
@@ -1944,7 +1991,9 @@ Q: String or long first?
return;
}
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
+ if ((mysql_result = (MYSQL_RES*)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (row < 0 || row >= (int)mysql_num_rows(mysql_result)) {
php_error_docref(NULL, E_WARNING, "Unable to jump to row %pd on MySQL result index %d", row, Z_RES_P(result)->handle);
@@ -2029,7 +2078,9 @@ PHP_FUNCTION(mysql_num_rows)
return;
}
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
+ if ((mysql_result = (MYSQL_RES*)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
/* conversion from int64 to long happing here */
RETURN_LONG((zend_long) mysql_num_rows(mysql_result));
@@ -2047,7 +2098,9 @@ PHP_FUNCTION(mysql_num_fields)
return;
}
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
+ if ((mysql_result = (MYSQL_RES*)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(mysql_num_fields(mysql_result));
}
@@ -2116,7 +2169,9 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_
result_type = MYSQL_BOTH;
}
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, res, -1, "MySQL result", le_result);
+ if ((mysql_result = (MYSQL_RES*)zend_fetch_resource_ex(res, "MySQL result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
#ifndef MYSQL_USE_MYSQLND
if ((mysql_row = mysql_fetch_row(mysql_result)) == NULL ||
@@ -2274,7 +2329,9 @@ PHP_FUNCTION(mysql_data_seek)
return;
}
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
+ if ((mysql_result = zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (offset < 0 || offset >= (int)mysql_num_rows(mysql_result)) {
php_error_docref(NULL, E_WARNING, "Offset %pd is invalid for MySQL result index %d (or the query data is unbuffered)", offset, Z_RES_P(result)->handle);
@@ -2299,7 +2356,9 @@ PHP_FUNCTION(mysql_fetch_lengths)
return;
}
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
+ if ((mysql_result = (MYSQL_RES *)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if ((lengths=mysql_fetch_lengths(mysql_result))==NULL) {
RETURN_FALSE;
@@ -2402,7 +2461,9 @@ PHP_FUNCTION(mysql_fetch_field)
return;
}
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
+ if ((mysql_result = (MYSQL_RES *)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (ZEND_NUM_ARGS() > 1) {
if (field<0 || field >= (int)mysql_num_fields(mysql_result)) {
@@ -2447,7 +2508,10 @@ PHP_FUNCTION(mysql_field_seek)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &result, &offset) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
+
+ if ((mysql_result = (MYSQL_RES *)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (offset < 0 || offset >= (int)mysql_num_fields(mysql_result)) {
php_error_docref(NULL, E_WARNING, "Field %pd is invalid for MySQL result index %d", offset, Z_RES_P(result)->handle);
@@ -2479,7 +2543,9 @@ static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
return;
}
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
+ if ((mysql_result = (MYSQL_RES *)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (field < 0 || field >= (int)mysql_num_fields(mysql_result)) {
php_error_docref(NULL, E_WARNING, "Field %pd is invalid for MySQL result index %d", field, Z_RES_P(result)->handle);
@@ -2636,7 +2702,9 @@ PHP_FUNCTION(mysql_free_result)
return;
}
- ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
+ if ((mysql_result = (MYSQL_RES *)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
zend_list_close(Z_RES_P(result));
RETURN_TRUE;
@@ -2659,7 +2727,9 @@ PHP_FUNCTION(mysql_ping)
CHECK_LINK(res);
mysql = (php_mysql_conn*)res->ptr;
} else {
- ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
+ if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", NULL, le_link, le_plink))) {
+ RETURN_FALSE;
+ }
}
PHPMY_UNBUFFERED_QUERY_CHECK();
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 58f1cb5316..e3b4f4899e 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -1351,9 +1351,8 @@ 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;
- int type;
- what = zend_fetch_resource(val, -1, "OpenSSL X.509", &type, 1, le_x509);
+ what = zend_fetch_resource_ex(val, "OpenSSL X.509", le_x509);
if (!what) {
return NULL;
}
@@ -1362,12 +1361,7 @@ static X509 * php_openssl_x509_from_zval(zval * val, int makeresource, zend_reso
*resourceval = Z_RES_P(val);
Z_ADDREF_P(val);
}
- if (type == le_x509) {
- return (X509*)what;
- }
- /* other types could be used here - eg: file pointers and read in the data from them */
-
- return NULL;
+ return (X509*)what;
}
if (!(Z_TYPE_P(val) == IS_STRING || Z_TYPE_P(val) == IS_OBJECT)) {
@@ -1407,7 +1401,7 @@ static X509 * php_openssl_x509_from_zval(zval * val, int makeresource, zend_reso
}
if (cert && makeresource && resourceval) {
- *resourceval = zend_register_resource(NULL, cert, le_x509);
+ *resourceval = zend_register_resource(cert, le_x509);
}
return cert;
}
@@ -2289,7 +2283,9 @@ PHP_FUNCTION(openssl_x509_free)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &x509) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(cert, X509 *, x509, -1, "OpenSSL X.509", le_x509);
+ if ((cert = (X509 *)zend_fetch_resource(Z_RES_P(x509), "OpenSSL X.509", le_x509)) == NULL) {
+ RETURN_FALSE;
+ }
zend_list_close(Z_RES_P(x509));
}
/* }}} */
@@ -2766,9 +2762,8 @@ static X509_REQ * php_openssl_csr_from_zval(zval * val, int makeresource, zend_r
}
if (Z_TYPE_P(val) == IS_RESOURCE) {
void * what;
- int type;
- what = zend_fetch_resource(val, -1, "OpenSSL X.509 CSR", &type, 1, le_csr);
+ what = zend_fetch_resource_ex(val, "OpenSSL X.509 CSR", le_csr);
if (what) {
if (resourceval) {
*resourceval = Z_RES_P(val);
@@ -2997,7 +2992,7 @@ PHP_FUNCTION(openssl_csr_sign)
}
/* Succeeded; lets return the cert */
- zend_register_resource(return_value, new_cert, le_x509);
+ ZVAL_RES(return_value, zend_register_resource(new_cert, le_x509));
new_cert = NULL;
cleanup:
@@ -3074,7 +3069,7 @@ PHP_FUNCTION(openssl_csr_new)
RETVAL_TRUE;
if (X509_REQ_sign(csr, req.priv_key, req.digest)) {
- zend_register_resource(return_value, csr, le_csr);
+ ZVAL_RES(return_value, zend_register_resource(csr, le_csr));
csr = NULL;
} else {
php_error_docref(NULL, E_WARNING, "Error signing request");
@@ -3083,7 +3078,7 @@ PHP_FUNCTION(openssl_csr_new)
if (we_made_the_key) {
/* and a resource for the private key */
zval_dtor(out_pkey);
- zend_register_resource(out_pkey, req.priv_key, le_key);
+ ZVAL_RES(out_pkey, zend_register_resource(req.priv_key, le_key));
req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */
} else if (key_resource != NULL) {
req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */
@@ -3156,8 +3151,7 @@ PHP_FUNCTION(openssl_csr_get_public_key)
}
tpubkey=X509_REQ_get_pubkey(csr);
- zend_register_resource(return_value, tpubkey, le_key);
- return;
+ RETURN_RES(zend_register_resource(tpubkey, le_key));
}
/* }}} */
@@ -3227,7 +3221,7 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval * val, int public_key, char * p
void * what;
int type;
- what = zend_fetch_resource(val, -1, "OpenSSL X.509/key", &type, 2, le_x509, le_key);
+ what = zend_fetch_resource2_ex(val, "OpenSSL X.509/key", &type, le_x509, le_key);
if (!what) {
TMP_CLEAN;
}
@@ -3326,7 +3320,7 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval * val, int public_key, char * p
X509_free(cert);
}
if (key && makeresource && resourceval) {
- *resourceval = ZEND_REGISTER_RESOURCE(NULL, key, le_key);
+ *resourceval = zend_register_resource(key, le_key);
}
if (Z_TYPE(tmp) == IS_STRING) {
zval_dtor(&tmp);
@@ -3519,8 +3513,7 @@ PHP_FUNCTION(openssl_pkey_new)
OPENSSL_PKEY_SET_BN(Z_ARRVAL_P(data), rsa, iqmp);
if (rsa->n && rsa->d) {
if (EVP_PKEY_assign_RSA(pkey, rsa)) {
- zend_register_resource(return_value, pkey, le_key);
- return;
+ RETURN_RES(zend_register_resource(pkey, le_key));
}
}
RSA_free(rsa);
@@ -3544,8 +3537,7 @@ PHP_FUNCTION(openssl_pkey_new)
DSA_generate_key(dsa);
}
if (EVP_PKEY_assign_DSA(pkey, dsa)) {
- zend_register_resource(return_value, pkey, le_key);
- return;
+ RETURN_RES(zend_register_resource(pkey, le_key));
}
}
DSA_free(dsa);
@@ -3586,7 +3578,7 @@ PHP_FUNCTION(openssl_pkey_new)
{
if (php_openssl_generate_private_key(&req)) {
/* pass back a key resource */
- zend_register_resource(return_value, req.priv_key, le_key);
+ RETVAL_RES(zend_register_resource(req.priv_key, le_key));
/* make sure the cleanup code doesn't zap it! */
req.priv_key = NULL;
}
@@ -3775,7 +3767,9 @@ PHP_FUNCTION(openssl_pkey_free)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &key) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(pkey, EVP_PKEY *, key, -1, "OpenSSL key", le_key);
+ if ((pkey = (EVP_PKEY *)zend_fetch_resource(Z_RES_P(key), "OpenSSL key", le_key)) == NULL) {
+ RETURN_FALSE;
+ }
zend_list_close(Z_RES_P(key));
}
/* }}} */
@@ -3818,8 +3812,7 @@ PHP_FUNCTION(openssl_pkey_get_details)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &key) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(pkey, EVP_PKEY *, key, -1, "OpenSSL key", le_key);
- if (!pkey) {
+ if ((pkey = (EVP_PKEY *)zend_fetch_resource(Z_RES_P(key), "OpenSSL key", le_key)) == NULL) {
RETURN_FALSE;
}
out = BIO_new(BIO_s_mem());
@@ -5350,8 +5343,10 @@ PHP_FUNCTION(openssl_dh_compute_key)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sr", &pub_str, &pub_len, &key) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(pkey, EVP_PKEY *, key, -1, "OpenSSL key", le_key);
- if (!pkey || EVP_PKEY_type(pkey->type) != EVP_PKEY_DH || !pkey->pkey.dh) {
+ if ((pkey = (EVP_PKEY *)zend_fetch_resource(Z_RES_P(key), "OpenSSL key", le_key)) == NULL) {
+ RETURN_FALSE;
+ }
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DH || !pkey->pkey.dh) {
RETURN_FALSE;
}
diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c
index c9a46a8c20..e70841979c 100644
--- a/ext/openssl/xp_ssl.c
+++ b/ext/openssl/xp_ssl.c
@@ -1563,7 +1563,7 @@ static int capture_peer_certs(php_stream *stream, php_openssl_netstream_data_t *
"ssl", "capture_peer_cert")) &&
zend_is_true(val)
) {
- zend_register_resource(&zcert, peer_cert, php_openssl_get_x509_list_id());
+ ZVAL_RES(&zcert, zend_register_resource(peer_cert, php_openssl_get_x509_list_id()));
php_stream_context_set_option(PHP_STREAM_CONTEXT(stream), "ssl", "peer_certificate", &zcert);
cert_captured = 1;
}
@@ -1583,7 +1583,7 @@ static int capture_peer_certs(php_stream *stream, php_openssl_netstream_data_t *
for (i = 0; i < sk_X509_num(chain); i++) {
X509 *mycert = X509_dup(sk_X509_value(chain, i));
- zend_register_resource(&zcert, mycert, php_openssl_get_x509_list_id());
+ ZVAL_RES(&zcert, zend_register_resource(mycert, php_openssl_get_x509_list_id()));
add_next_index_zval(&arr, &zcert);
}
diff --git a/ext/shmop/shmop.c b/ext/shmop/shmop.c
index 3377405701..0779d27671 100644
--- a/ext/shmop/shmop.c
+++ b/ext/shmop/shmop.c
@@ -215,8 +215,7 @@ PHP_FUNCTION(shmop_open)
shmop->size = shm.shm_segsz;
- ZEND_REGISTER_RESOURCE(return_value, shmop, shm_type);
- RETURN_LONG(Z_RES_HANDLE_P(return_value));
+ RETURN_RES(zend_register_resource(shmop, shm_type));
err:
efree(shmop);
RETURN_FALSE;
@@ -227,17 +226,20 @@ err:
reads from a shm segment */
PHP_FUNCTION(shmop_read)
{
- zend_long shmid, start, count;
+ zval *shmid;
+ zend_long start, count;
struct php_shmop *shmop;
char *startaddr;
int bytes;
zend_string *return_string;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &shmid, &start, &count) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rll", &shmid, &start, &count) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(shmop, struct php_shmop *, NULL, shmid, "shmop", shm_type);
+ if ((shmop = (struct php_shmop *)zend_fetch_resource(Z_RES_P(shmid), "shmop", shm_type))) {
+ RETURN_FALSE;
+ }
if (start < 0 || start > shmop->size) {
php_error_docref(NULL, E_WARNING, "start is out of range");
@@ -280,14 +282,16 @@ PHP_FUNCTION(shmop_close)
returns the shm size */
PHP_FUNCTION(shmop_size)
{
- zend_long shmid;
+ zval *shmid;
struct php_shmop *shmop;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &shmid) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &shmid) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(shmop, struct php_shmop *, NULL, shmid, "shmop", shm_type);
+ if ((shmop = (struct php_shmop *)zend_fetch_resource(Z_RES_P(shmid), "shmop", shm_type))) {
+ RETURN_FALSE;
+ }
RETURN_LONG(shmop->size);
}
@@ -299,14 +303,17 @@ PHP_FUNCTION(shmop_write)
{
struct php_shmop *shmop;
int writesize;
- zend_long shmid, offset;
+ zend_long offset;
zend_string *data;
+ zval *shmid;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "lSl", &shmid, &data, &offset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rSl", &shmid, &data, &offset) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(shmop, struct php_shmop *, NULL, shmid, "shmop", shm_type);
+ if ((shmop = (struct php_shmop *)zend_fetch_resource(Z_RES_P(shmid), "shmop", shm_type))) {
+ RETURN_FALSE;
+ }
if ((shmop->shmatflg & SHM_RDONLY) == SHM_RDONLY) {
php_error_docref(NULL, E_WARNING, "trying to write to a read only segment");
@@ -329,14 +336,16 @@ PHP_FUNCTION(shmop_write)
mark segment for deletion */
PHP_FUNCTION(shmop_delete)
{
- zend_long shmid;
+ zval *shmid;
struct php_shmop *shmop;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &shmid) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &shmid) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(shmop, struct php_shmop *, NULL, shmid, "shmop", shm_type);
+ if ((shmop = (struct php_shmop *)zend_fetch_resource(Z_RES_P(shmid), "shmop", shm_type))) {
+ RETURN_FALSE;
+ }
if (shmctl(shmop->shmid, IPC_RMID, NULL)) {
php_error_docref(NULL, E_WARNING, "can't mark segment for deletion (are you the owner?)");
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index 4d53888487..db0e3c14ca 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -471,7 +471,7 @@ try_again:
if (stream != NULL) {
php_url *orig;
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "httpurl", sizeof("httpurl")-1)) != NULL &&
- (orig = (php_url *) zend_fetch_resource(tmp, -1, "httpurl", NULL, 1, le_url)) != NULL &&
+ (orig = (php_url *) zend_fetch_resource_ex(tmp, "httpurl", le_url)) != NULL &&
((use_proxy && !use_ssl) ||
(((use_ssl && orig->scheme != NULL && strcmp(orig->scheme, "https") == 0) ||
(!use_ssl && orig->scheme == NULL) ||
@@ -517,7 +517,7 @@ try_again:
if (stream) {
zval *cookies, *login, *password;
- zend_resource *ret = zend_register_resource(NULL, phpurl, le_url);
+ zend_resource *ret = zend_register_resource(phpurl, le_url);
add_property_resource(this_ptr, "httpurl", ret);
/*zend_list_addref(ret);*/
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index a993b2ef8c..4308f3885f 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -139,16 +139,16 @@ static void soap_error_handler(int error_num, const char *error_filename, const
}
#define FIND_SDL_PROPERTY(ss,tmp) (tmp = zend_hash_str_find(Z_OBJPROP_P(ss), "sdl", sizeof("sdl")-1))
-#define FETCH_SDL_RES(ss,tmp) ss = (sdlPtr) zend_fetch_resource(tmp, -1, "sdl", NULL, 1, le_sdl)
+#define FETCH_SDL_RES(ss,tmp) ss = (sdlPtr) zend_fetch_resource_ex(tmp, "sdl", le_sdl)
#define FIND_TYPEMAP_PROPERTY(ss,tmp) (tmp = zend_hash_str_find(Z_OBJPROP_P(ss), "typemap", sizeof("typemap")-1))
-#define FETCH_TYPEMAP_RES(ss,tmp) ss = (HashTable*) zend_fetch_resource(tmp, -1, "typemap", NULL, 1, le_typemap)
+#define FETCH_TYPEMAP_RES(ss,tmp) ss = (HashTable*) zend_fetch_resource_ex(tmp, "typemap", le_typemap)
#define FETCH_THIS_SERVICE(ss) \
{ \
zval *tmp; \
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(getThis()),"service", sizeof("service")-1)) != NULL) { \
- ss = (soapServicePtr)zend_fetch_resource(tmp, -1, "service", NULL, 1, le_service); \
+ ss = (soapServicePtr)zend_fetch_resource_ex(tmp, "service", le_service); \
} else { \
php_error_docref(NULL, E_WARNING, "Can not fetch service object"); \
SOAP_SERVER_END_CODE(); \
@@ -1245,7 +1245,7 @@ PHP_METHOD(SoapServer, SoapServer)
service->typemap = soap_create_typemap(service->sdl, typemap_ht);
}
- res = zend_register_resource(NULL, service, le_service);
+ res = zend_register_resource(service, le_service);
add_property_resource(getThis(), "service", res);
SOAP_SERVER_END_CODE();
@@ -2252,7 +2252,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
if (Z_OBJ(SOAP_GLOBAL(error_object)) &&
instanceof_function(Z_OBJCE(SOAP_GLOBAL(error_object)), soap_server_class_entry) &&
(tmp = zend_hash_str_find(Z_OBJPROP(SOAP_GLOBAL(error_object)), "service", sizeof("service")-1)) != NULL &&
- (service = (soapServicePtr)zend_fetch_resource(tmp, -1, "service", NULL, 1, le_service)) &&
+ (service = (soapServicePtr)zend_fetch_resource_ex(tmp, "service", le_service)) &&
!service->send_errors) {
strcpy(buffer, "Internal Error");
} else {
@@ -2547,7 +2547,7 @@ PHP_METHOD(SoapClient, SoapClient)
SOAP_GLOBAL(soap_version) = soap_version;
sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl), cache_wsdl);
- res = zend_register_resource(NULL, sdl, le_sdl);
+ res = zend_register_resource(sdl, le_sdl);
add_property_resource(this_ptr, "sdl", res);
@@ -2559,7 +2559,7 @@ PHP_METHOD(SoapClient, SoapClient)
if (typemap) {
zend_resource *res;
- res = zend_register_resource(NULL, typemap, le_typemap);
+ res = zend_register_resource(typemap, le_typemap);
add_property_resource(this_ptr, "typemap", res);
}
}
diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c
index 27638f361f..270648c5e3 100644
--- a/ext/sockets/conversions.c
+++ b/ext/sockets/conversions.c
@@ -1351,15 +1351,13 @@ static void from_zval_write_fd_array_aux(zval *elem, unsigned i, void **args, se
php_stream *stream;
php_socket *sock;
- ZEND_FETCH_RESOURCE_NO_RETURN(sock, php_socket *, elem, -1,
- NULL, php_sockets_le_socket());
+ sock = (php_socket *)zend_fetch_resource_ex(elem, NULL, php_sockets_le_socket());
if (sock) {
iarr[i] = sock->bsd_socket;
return;
}
- ZEND_FETCH_RESOURCE2_NO_RETURN(stream, php_stream *, elem, -1,
- NULL, php_file_le_stream(), php_file_le_pstream());
+ stream = (php_stream *)zend_fetch_resource2_ex(elem, NULL, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
do_from_zval_err(ctx, "resource is not a stream or a socket");
return;
@@ -1423,7 +1421,7 @@ void to_zval_read_fd_array(const char *data, zval *zv, res_context *ctx)
}
if (S_ISSOCK(statbuf.st_mode)) {
php_socket *sock = socket_import_file_descriptor(fd);
- zend_register_resource(&elem, sock, php_sockets_le_socket());
+ ZVAL_RES(&elem, zend_register_resource(sock, php_sockets_le_socket()));
} else {
php_stream *stream = php_stream_fopen_from_fd(fd, "rw", NULL);
php_stream_to_zval(stream, &elem);
diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c
index 32382da7e0..cccaf4c407 100644
--- a/ext/sockets/sendrecvmsg.c
+++ b/ext/sockets/sendrecvmsg.c
@@ -181,8 +181,10 @@ PHP_FUNCTION(socket_sendmsg)
LONG_CHECK_VALID_INT(flags);
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, zsocket, -1,
- php_sockets_le_socket_name, php_sockets_le_socket());
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(zsocket),
+ php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) {
+ RETURN_FALSE;
+ }
msghdr = from_zval_run_conversions(zmsg, php_sock, from_zval_write_msghdr_send,
sizeof(*msghdr), "msghdr", &allocations, &err);
@@ -224,8 +226,10 @@ PHP_FUNCTION(socket_recvmsg)
LONG_CHECK_VALID_INT(flags);
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, zsocket, -1,
- php_sockets_le_socket_name, php_sockets_le_socket());
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(zsocket),
+ php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) {
+ RETURN_FALSE;
+ }
msghdr = from_zval_run_conversions(zmsg, php_sock, from_zval_write_msghdr_recv,
sizeof(*msghdr), "msghdr", &allocations, &err);
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index a1176ab85f..68d75e8d3b 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -781,7 +781,7 @@ static int php_sock_array_to_fd_set(zval *sock_array, fd_set *fds, PHP_SOCKET *m
if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0;
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(sock_array), element) {
- php_sock = (php_socket*) zend_fetch_resource(element, -1, le_socket_name, NULL, 1, le_socket);
+ php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
if (!php_sock) continue; /* If element is not a resource, skip it */
PHP_SAFE_FD_SET(php_sock->bsd_socket, fds);
@@ -809,7 +809,7 @@ static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds) /* {{{ */
array_init(&new_hash);
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(sock_array), num_key, key, element) {
- php_sock = (php_socket*) zend_fetch_resource(element, -1, le_socket_name, NULL, 1, le_socket);
+ php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
if (!php_sock) continue; /* If element is not a resource, skip it */
if (PHP_SAFE_FD_ISSET(php_sock->bsd_socket, fds)) {
@@ -927,7 +927,7 @@ PHP_FUNCTION(socket_create_listen)
php_sock->error = 0;
php_sock->blocking = 1;
- ZEND_REGISTER_RESOURCE(return_value, php_sock, le_socket);
+ RETURN_RES(zend_register_resource(php_sock, le_socket));
}
/* }}} */
@@ -944,13 +944,15 @@ PHP_FUNCTION(socket_accept)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
if (!php_accept_connect(php_sock, &new_sock, (struct sockaddr*)&sa, &php_sa_len)) {
RETURN_FALSE;
}
- ZEND_REGISTER_RESOURCE(return_value, new_sock, le_socket);
+ RETURN_RES(zend_register_resource(new_sock, le_socket));
}
/* }}} */
@@ -965,13 +967,14 @@ PHP_FUNCTION(socket_set_nonblock)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
if (!Z_ISUNDEF(php_sock->zstream)) {
php_stream *stream;
/* omit notice if resource doesn't exist anymore */
- stream = zend_fetch_resource(&php_sock->zstream, -1,
- NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
+ stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream != NULL) {
if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, 0,
NULL) != -1) {
@@ -1002,15 +1005,16 @@ PHP_FUNCTION(socket_set_block)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
/* if socket was created from a stream, give the stream a chance to take
* care of the operation itself, thereby allowing it to update its internal
* state */
if (!Z_ISUNDEF(php_sock->zstream)) {
php_stream *stream;
- stream = zend_fetch_resource(&php_sock->zstream, -1,
- NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
+ stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream != NULL) {
if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, 1,
NULL) != -1) {
@@ -1042,7 +1046,9 @@ PHP_FUNCTION(socket_listen)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
if (listen(php_sock->bsd_socket, backlog) != 0) {
PHP_SOCKET_ERROR(php_sock, "unable to listen on socket", errno);
@@ -1063,7 +1069,10 @@ PHP_FUNCTION(socket_close)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
+
if (!Z_ISUNDEF(php_sock->zstream)) {
php_stream *stream = NULL;
php_stream_from_zval_no_verify(stream, &php_sock->zstream);
@@ -1093,7 +1102,9 @@ PHP_FUNCTION(socket_write)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
if (ZEND_NUM_ARGS() < 3) {
length = str_len;
@@ -1135,7 +1146,9 @@ PHP_FUNCTION(socket_read)
tmpbuf = zend_string_alloc(length, 0);
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
if (type == PHP_NORMAL_READ) {
retval = php_read(php_sock, tmpbuf->val, length, 0);
@@ -1193,7 +1206,9 @@ PHP_FUNCTION(socket_getsockname)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
sa = (struct sockaddr *) &sa_storage;
@@ -1274,7 +1289,9 @@ PHP_FUNCTION(socket_getpeername)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
sa = (struct sockaddr *) &sa_storage;
@@ -1371,7 +1388,7 @@ PHP_FUNCTION(socket_create)
php_sock->error = 0;
php_sock->blocking = 1;
- ZEND_REGISTER_RESOURCE(return_value, php_sock, le_socket);
+ RETURN_RES(zend_register_resource(php_sock, le_socket));
}
/* }}} */
@@ -1391,7 +1408,9 @@ PHP_FUNCTION(socket_connect)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
switch(php_sock->type) {
#if HAVE_IPV6
@@ -1495,7 +1514,9 @@ PHP_FUNCTION(socket_bind)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
switch(php_sock->type) {
case AF_UNIX:
@@ -1575,7 +1596,9 @@ PHP_FUNCTION(socket_recv)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, php_sock_res, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(php_sock_res), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
/* overflow check */
if ((len + 1) < 2) {
@@ -1621,7 +1644,9 @@ PHP_FUNCTION(socket_send)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
retval = send(php_sock->bsd_socket, buf, (buf_len < len ? buf_len : len), flags);
@@ -1656,7 +1681,9 @@ PHP_FUNCTION(socket_recvfrom)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
/* overflow check */
if ((arg3 + 2) < 3) {
@@ -1779,7 +1806,9 @@ PHP_FUNCTION(socket_sendto)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
switch (php_sock->type) {
case AF_UNIX:
@@ -1855,7 +1884,9 @@ PHP_FUNCTION(socket_get_option)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
if (level == IPPROTO_IP) {
switch (optname) {
@@ -1968,7 +1999,9 @@ PHP_FUNCTION(socket_set_option)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
set_errno(0);
@@ -2138,8 +2171,8 @@ PHP_FUNCTION(socket_create_pair)
php_sock[0]->blocking = 1;
php_sock[1]->blocking = 1;
- ZEND_REGISTER_RESOURCE(&retval[0], php_sock[0], le_socket);
- ZEND_REGISTER_RESOURCE(&retval[1], php_sock[1], le_socket);
+ ZVAL_RES(&retval[0], zend_register_resource(php_sock[0], le_socket));
+ ZVAL_RES(&retval[1], zend_register_resource(php_sock[1], le_socket));
add_index_zval(fds_array_zval, 0, &retval[0]);
add_index_zval(fds_array_zval, 1, &retval[1]);
@@ -2162,7 +2195,9 @@ PHP_FUNCTION(socket_shutdown)
return;
}
- ZEND_FETCH_RESOURCE(php_sock, php_socket*, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
if (shutdown(php_sock->bsd_socket, how_shutdown) != 0) {
PHP_SOCKET_ERROR(php_sock, "unable to shutdown socket", errno);
@@ -2186,7 +2221,9 @@ PHP_FUNCTION(socket_last_error)
}
if (arg1) {
- ZEND_FETCH_RESOURCE(php_sock, php_socket*, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
RETVAL_LONG(php_sock->error);
} else {
RETVAL_LONG(SOCKETS_G(last_error));
@@ -2206,7 +2243,9 @@ PHP_FUNCTION(socket_clear_error)
}
if (arg1) {
- ZEND_FETCH_RESOURCE(php_sock, php_socket*, arg1, -1, le_socket_name, le_socket);
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ RETURN_FALSE;
+ }
php_sock->error = 0;
} else {
SOCKETS_G(last_error) = 0;
@@ -2306,7 +2345,7 @@ PHP_FUNCTION(socket_import_stream)
php_stream_set_option(stream, PHP_STREAM_OPTION_READ_BUFFER,
PHP_STREAM_BUFFER_NONE, NULL);
- ZEND_REGISTER_RESOURCE(return_value, retsock, le_socket);
+ RETURN_RES(zend_register_resource(retsock, le_socket));
}
/* }}} */
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
index 9a26458321..b1d211a9c8 100644
--- a/ext/standard/dir.c
+++ b/ext/standard/dir.c
@@ -85,14 +85,19 @@ static zend_class_entry *dir_class_entry_ptr;
php_error_docref(NULL, E_WARNING, "Unable to find my handle property"); \
RETURN_FALSE; \
} \
- ZEND_FETCH_RESOURCE(dirp, php_stream *, tmp, -1, "Directory", php_file_le_stream()); \
+ if ((dirp = (php_stream *)zend_fetch_resource_ex(tmp, "Directory", php_file_le_stream())) == NULL) { \
+ RETURN_FALSE; \
+ } \
} else { \
- ZEND_FETCH_RESOURCE(dirp, php_stream *, 0, (int)DIRG(default_dir)->handle, "Directory", php_file_le_stream()); \
+ if (!DIRG(default_dir) || \
+ (dirp = (php_stream *)zend_fetch_resource(DIRG(default_dir), "Directory", php_file_le_stream())) == NULL) { \
+ RETURN_FALSE; \
+ } \
} \
} else { \
- dirp = (php_stream *) zend_fetch_resource(id, -1, "Directory", NULL, 1, php_file_le_stream()); \
- if (!dirp) \
+ if ((dirp = (php_stream *)zend_fetch_resource(Z_RES_P(id), "Directory", php_file_le_stream())) == NULL) { \
RETURN_FALSE; \
+ } \
}
/* {{{ arginfo */
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 27053fe271..5d9efa60a6 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -1165,7 +1165,7 @@ PHP_FUNCTION(fscanf)
return;
}
- what = zend_fetch_resource(file_handle, -1, "File-Handle", &type, 2, php_file_le_stream(), php_file_le_pstream());
+ what = zend_fetch_resource2(Z_RES_P(file_handle), "File-Handle", &type, php_file_le_stream(), php_file_le_pstream());
/* we can't do a ZEND_VERIFY_RESOURCE(what), otherwise we end up
* with a leak if we have an invalid filehandle. This needs changing
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index 940dc7f1c8..d774808a7b 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -266,7 +266,9 @@ PHP_FUNCTION(proc_terminate)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, "process", le_proc_open);
+ if ((proc = (struct php_process_handle *)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open)) == NULL) {
+ RETURN_FALSE;
+ }
#ifdef PHP_WIN32
if (TerminateProcess(proc->childHandle, 255)) {
@@ -295,7 +297,9 @@ PHP_FUNCTION(proc_close)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, "process", le_proc_open);
+ if ((proc = (struct php_process_handle *)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open)) == NULL) {
+ RETURN_FALSE;
+ }
FG(pclose_wait) = 1;
zend_list_close(Z_RES_P(zproc));
@@ -323,7 +327,9 @@ PHP_FUNCTION(proc_get_status)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, "process", le_proc_open);
+ if ((proc = (struct php_process_handle *)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open)) == NULL) {
+ RETURN_FALSE;
+ }
array_init(return_value);
@@ -946,7 +952,7 @@ PHP_FUNCTION(proc_open)
}
}
- ZEND_REGISTER_RESOURCE(return_value, proc, le_proc_open);
+ ZVAL_RES(return_value, zend_register_resource(proc, le_proc_open));
return;
exit_fail:
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index d5ee886ee9..f1e27e322f 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -916,11 +916,11 @@ static php_stream_context *decode_context_param(zval *contextresource)
{
php_stream_context *context = NULL;
- context = zend_fetch_resource(contextresource, -1, NULL, NULL, 1, php_le_stream_context());
+ context = zend_fetch_resource_ex(contextresource, NULL, php_le_stream_context());
if (context == NULL) {
php_stream *stream;
- stream = zend_fetch_resource(contextresource, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream);
+ stream = zend_fetch_resource2_ex(contextresource, NULL, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream) {
context = PHP_STREAM_CONTEXT(stream);
@@ -1182,7 +1182,7 @@ static void apply_filter_to_stream(int append, INTERNAL_FUNCTION_PARAMETERS)
}
if (filter) {
- filter->res = ZEND_REGISTER_RESOURCE(NULL, filter, php_file_le_stream_filter());
+ filter->res = zend_register_resource(filter, php_file_le_stream_filter());
GC_REFCOUNT(filter->res)++;
RETURN_RES(filter->res);
} else {
@@ -1218,7 +1218,7 @@ PHP_FUNCTION(stream_filter_remove)
RETURN_FALSE;
}
- filter = zend_fetch_resource(zfilter, -1, NULL, NULL, 1, php_file_le_stream_filter());
+ filter = zend_fetch_resource(Z_RES_P(zfilter), NULL, php_file_le_stream_filter());
if (!filter) {
php_error_docref(NULL, E_WARNING, "Invalid resource given, not a stream filter");
RETURN_FALSE;
diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c
index 7d2d886ba8..3e66449db5 100644
--- a/ext/standard/user_filters.c
+++ b/ext/standard/user_filters.c
@@ -40,15 +40,6 @@ static int le_userfilters;
static int le_bucket_brigade;
static int le_bucket;
-#define GET_FILTER_FROM_OBJ() { \
- zval **tmp; \
- if (FAILURE == zend_hash_index_find(Z_OBJPROP_P(this_ptr), 0, (void**)&tmp)) { \
- php_error_docref(NULL, E_WARNING, "filter property vanished"); \
- RETURN_FALSE; \
- } \
- ZEND_FETCH_RESOURCE(filter, php_stream_filter*, tmp, -1, "filter", le_userfilters); \
-}
-
/* define the base filter class */
PHP_FUNCTION(user_filter_nop)
@@ -198,9 +189,8 @@ php_stream_filter_status_t userfilter_filter(
ZVAL_STRINGL(&func_name, "filter", sizeof("filter")-1);
/* Setup calling arguments */
- ZEND_REGISTER_RESOURCE(&args[0], buckets_in, le_bucket_brigade);
-
- ZEND_REGISTER_RESOURCE(&args[1], buckets_out, le_bucket_brigade);
+ ZVAL_RES(&args[0], zend_register_resource(buckets_in, le_bucket_brigade));
+ ZVAL_RES(&args[1], zend_register_resource(buckets_out, le_bucket_brigade));
if (bytes_consumed) {
ZVAL_LONG(&args[2], *bytes_consumed);
@@ -381,7 +371,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
zval_ptr_dtor(&func_name);
/* set the filter property, this will be used during cleanup */
- ZEND_REGISTER_RESOURCE(&zfilter, filter, le_userfilters);
+ ZVAL_RES(&zfilter, zend_register_resource(filter, le_userfilters));
ZVAL_COPY_VALUE(&filter->abstract, &obj);
add_property_zval(&obj, "filter", &zfilter);
/* add_property_zval increments the refcount which is unwanted here */
@@ -409,16 +399,19 @@ PHP_FUNCTION(stream_bucket_make_writeable)
php_stream_bucket_brigade *brigade;
php_stream_bucket *bucket;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zbrigade) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zbrigade) == FAILURE) {
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(brigade, php_stream_bucket_brigade *, zbrigade, -1, PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade);
+ if ((brigade = (php_stream_bucket_brigade*)zend_fetch_resource(
+ Z_RES_P(zbrigade), PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade)) == NULL) {
+ RETURN_FALSE;
+ }
ZVAL_NULL(return_value);
if (brigade->head && (bucket = php_stream_bucket_make_writeable(brigade->head))) {
- ZEND_REGISTER_RESOURCE(&zbucket, bucket, le_bucket);
+ ZVAL_RES(&zbucket, zend_register_resource(bucket, le_bucket));
object_init(return_value);
add_property_zval(return_value, "bucket", &zbucket);
/* add_property_zval increments the refcount which is unwanted here */
@@ -437,7 +430,7 @@ static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
php_stream_bucket_brigade *brigade;
php_stream_bucket *bucket;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "zo", &zbrigade, &zobject) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ro", &zbrigade, &zobject) == FAILURE) {
RETURN_FALSE;
}
@@ -446,8 +439,14 @@ static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(brigade, php_stream_bucket_brigade *, zbrigade, -1, PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade);
- ZEND_FETCH_RESOURCE(bucket, php_stream_bucket *, pzbucket, -1, PHP_STREAM_BUCKET_RES_NAME, le_bucket);
+ if ((brigade = (php_stream_bucket_brigade*)zend_fetch_resource(
+ Z_RES_P(zbrigade), PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((bucket = (php_stream_bucket *)zend_fetch_resource_ex(pzbucket, PHP_STREAM_BUCKET_RES_NAME, le_bucket)) == NULL) {
+ RETURN_FALSE;
+ }
if (NULL != (pzdata = zend_hash_str_find(Z_OBJPROP_P(zobject), "data", sizeof("data")-1)) && Z_TYPE_P(pzdata) == IS_STRING) {
if (!bucket->own_buf) {
@@ -519,7 +518,7 @@ PHP_FUNCTION(stream_bucket_new)
RETURN_FALSE;
}
- ZEND_REGISTER_RESOURCE(&zbucket, bucket, le_bucket);
+ ZVAL_RES(&zbucket, zend_register_resource(bucket, le_bucket));
object_init(return_value);
add_property_zval(return_value, "bucket", &zbucket);
/* add_property_zval increments the refcount which is unwanted here */
diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c
index 61f8c765ed..7f4682c92e 100644
--- a/ext/sysvmsg/sysvmsg.c
+++ b/ext/sysvmsg/sysvmsg.c
@@ -164,7 +164,9 @@ PHP_FUNCTION(msg_set_queue)
return;
}
- ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, queue, -1, "sysvmsg queue", le_sysvmsg);
+ if ((mq = (sysvmsg_queue_t *)zend_fetch_resource(Z_RES_P(queue), "sysvmsg queue", le_sysvmsg)) == NULL) {
+ RETURN_FALSE;
+ }
if (msgctl(mq->id, IPC_STAT, &stat) == 0) {
zval *item;
@@ -207,7 +209,9 @@ PHP_FUNCTION(msg_stat_queue)
return;
}
- ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, queue, -1, "sysvmsg queue", le_sysvmsg);
+ if ((mq = (sysvmsg_queue_t *)zend_fetch_resource(Z_RES_P(queue), "sysvmsg queue", le_sysvmsg)) == NULL) {
+ RETURN_FALSE;
+ }
if (msgctl(mq->id, IPC_STAT, &stat) == 0) {
array_init(return_value);
@@ -284,7 +288,9 @@ PHP_FUNCTION(msg_remove_queue)
return;
}
- ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, queue, -1, "sysvmsg queue", le_sysvmsg);
+ if ((mq = (sysvmsg_queue_t *)zend_fetch_resource(Z_RES_P(queue), "sysvmsg queue", le_sysvmsg)) == NULL) {
+ RETURN_FALSE;
+ }
if (msgctl(mq->id, IPC_RMID, NULL) == 0) {
RETVAL_TRUE;
@@ -336,7 +342,9 @@ PHP_FUNCTION(msg_receive)
}
}
- ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, queue, -1, "sysvmsg queue", le_sysvmsg);
+ if ((mq = (sysvmsg_queue_t *)zend_fetch_resource(Z_RES_P(queue), "sysvmsg queue", le_sysvmsg)) == NULL) {
+ RETURN_FALSE;
+ }
messagebuffer = (struct php_msgbuf *) safe_emalloc(maxsize, 1, sizeof(struct php_msgbuf));
@@ -400,7 +408,9 @@ PHP_FUNCTION(msg_send)
return;
}
- ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t*, queue, -1, "sysvmsg queue", le_sysvmsg);
+ if ((mq = (sysvmsg_queue_t *)zend_fetch_resource(Z_RES_P(queue), "sysvmsg queue", le_sysvmsg)) == NULL) {
+ RETURN_FALSE;
+ }
if (do_serialize) {
smart_str msg_var = {0};
diff --git a/ext/sysvsem/sysvsem.c b/ext/sysvsem/sysvsem.c
index f23067bc95..647d59191c 100644
--- a/ext/sysvsem/sysvsem.c
+++ b/ext/sysvsem/sysvsem.c
@@ -290,7 +290,7 @@ PHP_FUNCTION(sem_get)
sem_ptr->count = 0;
sem_ptr->auto_release = auto_release;
- ZEND_REGISTER_RESOURCE(return_value, sem_ptr, php_sysvsem_module.le_sem);
+ RETVAL_RES(zend_register_resource(sem_ptr, php_sysvsem_module.le_sem));
sem_ptr->id = Z_RES_HANDLE_P(return_value);
}
/* }}} */
@@ -314,7 +314,9 @@ static void php_sysvsem_semop(INTERNAL_FUNCTION_PARAMETERS, int acquire)
}
}
- ZEND_FETCH_RESOURCE(sem_ptr, sysvsem_sem *, arg_id, -1, "SysV semaphore", php_sysvsem_module.le_sem);
+ if ((sem_ptr = (sysvsem_sem *)zend_fetch_resource(Z_RES_P(arg_id), "SysV semaphore", php_sysvsem_module.le_sem)) == NULL) {
+ RETURN_FALSE;
+ }
if (!acquire && sem_ptr->count == 0) {
php_error_docref(NULL, E_WARNING, "SysV semaphore %ld (key 0x%x) is not currently acquired", Z_LVAL_P(arg_id), sem_ptr->key);
@@ -376,7 +378,9 @@ PHP_FUNCTION(sem_remove)
return;
}
- ZEND_FETCH_RESOURCE(sem_ptr, sysvsem_sem *, arg_id, -1, "SysV semaphore", php_sysvsem_module.le_sem);
+ if ((sem_ptr = (sysvsem_sem *)zend_fetch_resource(Z_RES_P(arg_id), "SysV semaphore", php_sysvsem_module.le_sem)) == NULL) {
+ RETURN_FALSE;
+ }
#if HAVE_SEMUN
un.buf = &buf;
diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c
index 4d5e8a6de6..fb03e950db 100644
--- a/ext/sysvshm/sysvshm.c
+++ b/ext/sysvshm/sysvshm.c
@@ -112,7 +112,11 @@ ZEND_GET_MODULE(sysvshm)
#undef shm_ptr /* undefine AIX-specific macro */
-#define SHM_FETCH_RESOURCE(shm_ptr, z_ptr) ZEND_FETCH_RESOURCE(shm_ptr, sysvshm_shm *, z_ptr, -1, PHP_SHM_RSRC_NAME, php_sysvshm.le_shm)
+#define SHM_FETCH_RESOURCE(shm_ptr, z_ptr) do { \
+ if ((shm_ptr = (sysvshm_shm *)zend_fetch_resource(Z_RES_P(z_ptr), PHP_SHM_RSRC_NAME, php_sysvshm.le_shm)) == NULL) { \
+ RETURN_FALSE; \
+ } \
+} while (0)
THREAD_LS sysvshm_module php_sysvshm;
@@ -197,7 +201,7 @@ PHP_FUNCTION(shm_attach)
shm_list_ptr->id = shm_id;
shm_list_ptr->ptr = chunk_ptr;
- ZEND_REGISTER_RESOURCE(return_value, shm_list_ptr, php_sysvshm.le_shm);
+ RETURN_RES(zend_register_resource(shm_list_ptr, php_sysvshm.le_shm));
}
/* }}} */
@@ -257,7 +261,7 @@ PHP_FUNCTION(shm_put_var)
php_var_serialize(&shm_var, arg_var, &var_hash);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
- shm_list_ptr = zend_fetch_resource(shm_id, -1, PHP_SHM_RSRC_NAME, NULL, 1, php_sysvshm.le_shm);
+ shm_list_ptr = zend_fetch_resource(Z_RES_P(shm_id), PHP_SHM_RSRC_NAME, php_sysvshm.le_shm);
if (!shm_list_ptr) {
smart_str_free(&shm_var);
RETURN_FALSE;
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index 83ee7db080..10767d8545 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -1141,7 +1141,7 @@ static void php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAMETERS, int ns_supp
XML_SetUserData(parser->parser, parser);
- ZEND_REGISTER_RESOURCE(return_value, parser, le_xml_parser);
+ RETVAL_RES(zend_register_resource(parser, le_xml_parser));
ZVAL_COPY(&parser->index, return_value);
}
/* }}} */
@@ -1173,7 +1173,9 @@ PHP_FUNCTION(xml_set_object)
return;
}
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
/* please leave this commented - or ask thies@thieso.net before doing it (again) */
if (!Z_ISUNDEF(parser->object)) {
@@ -1202,7 +1204,9 @@ PHP_FUNCTION(xml_set_element_handler)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
xml_set_handler(&parser->startElementHandler, shdl);
xml_set_handler(&parser->endElementHandler, ehdl);
@@ -1222,7 +1226,9 @@ PHP_FUNCTION(xml_set_character_data_handler)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
xml_set_handler(&parser->characterDataHandler, hdl);
XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler);
@@ -1241,7 +1247,9 @@ PHP_FUNCTION(xml_set_processing_instruction_handler)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
xml_set_handler(&parser->processingInstructionHandler, hdl);
XML_SetProcessingInstructionHandler(parser->parser, _xml_processingInstructionHandler);
@@ -1260,7 +1268,9 @@ PHP_FUNCTION(xml_set_default_handler)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
xml_set_handler(&parser->defaultHandler, hdl);
XML_SetDefaultHandler(parser->parser, _xml_defaultHandler);
@@ -1279,7 +1289,9 @@ PHP_FUNCTION(xml_set_unparsed_entity_decl_handler)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
xml_set_handler(&parser->unparsedEntityDeclHandler, hdl);
XML_SetUnparsedEntityDeclHandler(parser->parser, _xml_unparsedEntityDeclHandler);
@@ -1297,7 +1309,10 @@ PHP_FUNCTION(xml_set_notation_decl_handler)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz", &pind, &hdl) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
xml_set_handler(&parser->notationDeclHandler, hdl);
XML_SetNotationDeclHandler(parser->parser, _xml_notationDeclHandler);
@@ -1315,7 +1330,10 @@ PHP_FUNCTION(xml_set_external_entity_ref_handler)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz", &pind, &hdl) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
xml_set_handler(&parser->externalEntityRefHandler, hdl);
XML_SetExternalEntityRefHandler(parser->parser, (void *) _xml_externalEntityRefHandler);
@@ -1334,7 +1352,9 @@ PHP_FUNCTION(xml_set_start_namespace_decl_handler)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
xml_set_handler(&parser->startNamespaceDeclHandler, hdl);
XML_SetStartNamespaceDeclHandler(parser->parser, _xml_startNamespaceDeclHandler);
@@ -1353,7 +1373,9 @@ PHP_FUNCTION(xml_set_end_namespace_decl_handler)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
xml_set_handler(&parser->endNamespaceDeclHandler, hdl);
XML_SetEndNamespaceDeclHandler(parser->parser, _xml_endNamespaceDeclHandler);
@@ -1375,7 +1397,10 @@ PHP_FUNCTION(xml_parse)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|l", &pind, &data, &data_len, &isFinal) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
parser->isparsing = 1;
ret = XML_Parse(parser->parser, (XML_Char*)data, data_len, isFinal);
@@ -1405,7 +1430,9 @@ PHP_FUNCTION(xml_parse_into_struct)
array_init(info);
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
zval_ptr_dtor(xdata);
array_init(xdata);
@@ -1442,7 +1469,9 @@ PHP_FUNCTION(xml_get_error_code)
return;
}
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG((zend_long)XML_GetErrorCode(parser->parser));
}
@@ -1477,7 +1506,9 @@ PHP_FUNCTION(xml_get_current_line_number)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
RETVAL_LONG(XML_GetCurrentLineNumber(parser->parser));
}
@@ -1494,7 +1525,9 @@ PHP_FUNCTION(xml_get_current_column_number)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
RETVAL_LONG(XML_GetCurrentColumnNumber(parser->parser));
}
@@ -1511,7 +1544,9 @@ PHP_FUNCTION(xml_get_current_byte_index)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
RETVAL_LONG(XML_GetCurrentByteIndex(parser->parser));
}
@@ -1529,7 +1564,9 @@ PHP_FUNCTION(xml_parser_free)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
if (parser->isparsing == 1) {
php_error_docref(NULL, E_WARNING, "Parser cannot be freed while it is parsing.");
@@ -1555,7 +1592,9 @@ PHP_FUNCTION(xml_parser_set_option)
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
switch (opt) {
case PHP_XML_OPTION_CASE_FOLDING:
@@ -1601,7 +1640,10 @@ PHP_FUNCTION(xml_parser_get_option)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &pind, &opt) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
+
+ if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
+ RETURN_FALSE;
+ }
switch (opt) {
case PHP_XML_OPTION_CASE_FOLDING:
diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c
index 914ec4989e..228cbc4c03 100644
--- a/ext/xmlrpc/xmlrpc-epi-php.c
+++ b/ext/xmlrpc/xmlrpc-epi-php.c
@@ -827,7 +827,7 @@ PHP_FUNCTION(xmlrpc_server_create)
XMLRPC_ServerRegisterIntrospectionCallback(server->server_ptr, php_xmlrpc_introspection_callback);
/* store for later use */
- ZEND_REGISTER_RESOURCE(return_value, server, le_xmlrpc_server);
+ RETURN_RES(zend_register_resource(server, le_xmlrpc_server));
}
}
/* }}} */
@@ -844,14 +844,14 @@ PHP_FUNCTION(xmlrpc_server_destroy)
return;
}
- ZEND_FETCH_RESOURCE(server, xmlrpc_server_data*, arg1, -1, "xmlrpc server", le_xmlrpc_server);
-
- if (server) {
- bSuccess = zend_list_close(Z_RES_P(arg1));
- /* called by hashtable destructor
- * destroy_server_data(server);
- */
+ if ((server = (xmlrpc_server_data *)zend_fetch_resource(Z_RES_P(arg1), "xmlrpc server", le_xmlrpc_server)) == NULL) {
+ RETURN_FALSE;
}
+
+ bSuccess = zend_list_close(Z_RES_P(arg1));
+ /* called by hashtable destructor
+ * destroy_server_data(server);
+ */
RETURN_BOOL(bSuccess == SUCCESS);
}
/* }}} */
@@ -964,7 +964,9 @@ PHP_FUNCTION(xmlrpc_server_register_method)
return;
}
- ZEND_FETCH_RESOURCE(server, xmlrpc_server_data*, handle, -1, "xmlrpc server", le_xmlrpc_server);
+ if ((server = (xmlrpc_server_data *)zend_fetch_resource(Z_RES_P(handle), "xmlrpc server", le_xmlrpc_server)) == NULL) {
+ RETURN_FALSE;
+ }
/* register with C engine. every method just calls our standard callback,
* and it then dispatches to php as necessary
@@ -994,7 +996,9 @@ PHP_FUNCTION(xmlrpc_server_register_introspection_callback)
return;
}
- ZEND_FETCH_RESOURCE(server, xmlrpc_server_data*, handle, -1, "xmlrpc server", le_xmlrpc_server);
+ if ((server = (xmlrpc_server_data *)zend_fetch_resource(Z_RES_P(handle), "xmlrpc server", le_xmlrpc_server)) == NULL) {
+ RETURN_FALSE;
+ }
if (Z_REFCOUNTED_P(method_name)) {
Z_ADDREF_P(method_name);
@@ -1032,7 +1036,9 @@ PHP_FUNCTION(xmlrpc_server_call_method)
set_output_options(&out, output_opts);
}
- ZEND_FETCH_RESOURCE(server, xmlrpc_server_data*, handle, -1, "xmlrpc server", le_xmlrpc_server);
+ if ((server = (xmlrpc_server_data *)zend_fetch_resource(Z_RES_P(handle), "xmlrpc server", le_xmlrpc_server)) == NULL) {
+ RETURN_FALSE;
+ }
/* HACK: use output encoding for now */
input_opts.xml_elem_opts.encoding = utf8_get_encoding_id_from_string(out.xmlrpc_out.xml_elem_opts.encoding);
@@ -1122,7 +1128,9 @@ PHP_FUNCTION(xmlrpc_server_add_introspection_data)
return;
}
- ZEND_FETCH_RESOURCE(server, xmlrpc_server_data*, handle, -1, "xmlrpc server", le_xmlrpc_server);
+ if ((server = (xmlrpc_server_data *)zend_fetch_resource(Z_RES_P(handle), "xmlrpc server", le_xmlrpc_server)) == NULL) {
+ RETURN_FALSE;
+ }
xDesc = PHP_to_XMLRPC(desc);
if (xDesc) {
diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c
index e4a573df11..9e79e14ea5 100644
--- a/ext/xmlwriter/php_xmlwriter.c
+++ b/ext/xmlwriter/php_xmlwriter.c
@@ -709,7 +709,9 @@ static void php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_rea
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
if (err_string != NULL) {
@@ -745,7 +747,9 @@ static void php_xmlwriter_end(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_read_int_t
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -782,7 +786,9 @@ static PHP_FUNCTION(xmlwriter_set_indent)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rb", &pind, &indent) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
@@ -848,7 +854,9 @@ static PHP_FUNCTION(xmlwriter_start_attribute_ns)
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Attribute Name");
@@ -890,7 +898,9 @@ static PHP_FUNCTION(xmlwriter_write_attribute)
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Attribute Name");
@@ -933,7 +943,9 @@ static PHP_FUNCTION(xmlwriter_write_attribute_ns)
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Attribute Name");
@@ -983,7 +995,9 @@ static PHP_FUNCTION(xmlwriter_start_element_ns)
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1041,7 +1055,9 @@ static PHP_FUNCTION(xmlwriter_write_element)
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1093,7 +1109,9 @@ static PHP_FUNCTION(xmlwriter_write_element_ns)
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1162,7 +1180,9 @@ static PHP_FUNCTION(xmlwriter_write_pi)
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid PI Target");
@@ -1196,7 +1216,9 @@ static PHP_FUNCTION(xmlwriter_start_cdata)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -1261,7 +1283,9 @@ static PHP_FUNCTION(xmlwriter_start_comment)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -1317,7 +1341,9 @@ static PHP_FUNCTION(xmlwriter_start_document)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!s!", &pind, &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -1363,8 +1389,9 @@ static PHP_FUNCTION(xmlwriter_start_dtd)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
return;
}
-
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -1410,7 +1437,9 @@ static PHP_FUNCTION(xmlwriter_write_dtd)
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -1464,7 +1493,9 @@ static PHP_FUNCTION(xmlwriter_write_dtd_element)
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1522,7 +1553,9 @@ static PHP_FUNCTION(xmlwriter_write_dtd_attlist)
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1561,7 +1594,9 @@ static PHP_FUNCTION(xmlwriter_start_dtd_entity)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsb", &pind, &name, &name_len, &isparm) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Attribute Name");
@@ -1616,7 +1651,9 @@ static PHP_FUNCTION(xmlwriter_write_dtd_entity)
&sysid, &sysid_len, &ndataid, &ndataid_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1684,7 +1721,7 @@ static PHP_FUNCTION(xmlwriter_open_uri)
ze_obj->xmlwriter_ptr = intern;
RETURN_TRUE;
} else {
- ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
+ RETURN_RES(zend_register_resource(intern, le_xmlwriter));
}
}
/* }}} */
@@ -1727,7 +1764,7 @@ static PHP_FUNCTION(xmlwriter_open_memory)
ze_obj->xmlwriter_ptr = intern;
RETURN_TRUE;
} else {
- ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
+ RETURN_RES(zend_register_resource(intern, le_xmlwriter));
}
}
@@ -1753,7 +1790,9 @@ static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string)
return;
}
- ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 1a60f8acd4..927e66e794 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -1130,7 +1130,7 @@ static PHP_NAMED_FUNCTION(zif_zip_open)
rsrc_int->index_current = 0;
rsrc_int->num_files = zip_get_num_files(rsrc_int->za);
- ZEND_REGISTER_RESOURCE(return_value, rsrc_int, le_zip_dir);
+ RETURN_RES(zend_register_resource(rsrc_int, le_zip_dir));
}
/* }}} */
@@ -1144,7 +1144,10 @@ static PHP_NAMED_FUNCTION(zif_zip_close)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zip) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(z_rsrc, zip_rsrc *, zip, -1, le_zip_dir_name, le_zip_dir);
+
+ if ((z_rsrc = (zip_rsrc *)zend_fetch_resource(Z_RES_P(zip), le_zip_dir_name, le_zip_dir)) == NULL) {
+ RETURN_FALSE;
+ }
/* really close the zip will break BC :-D */
zend_list_close(Z_RES_P(zip));
@@ -1164,7 +1167,9 @@ static PHP_NAMED_FUNCTION(zif_zip_read)
return;
}
- ZEND_FETCH_RESOURCE(rsrc_int, zip_rsrc *, zip_dp, -1, le_zip_dir_name, le_zip_dir);
+ if ((rsrc_int = (zip_rsrc *)zend_fetch_resource(Z_RES_P(zip_dp), le_zip_dir_name, le_zip_dir)) == NULL) {
+ RETURN_FALSE;
+ }
if (rsrc_int && rsrc_int->za) {
if (rsrc_int->index_current >= rsrc_int->num_files) {
@@ -1183,7 +1188,7 @@ static PHP_NAMED_FUNCTION(zif_zip_read)
zr_rsrc->zf = zip_fopen_index(rsrc_int->za, rsrc_int->index_current, 0);
if (zr_rsrc->zf) {
rsrc_int->index_current++;
- ZEND_REGISTER_RESOURCE(return_value, zr_rsrc, le_zip_entry);
+ RETURN_RES(zend_register_resource(zr_rsrc, le_zip_entry));
} else {
efree(zr_rsrc);
RETURN_FALSE;
@@ -1211,8 +1216,13 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_open)
return;
}
- ZEND_FETCH_RESOURCE(zr_rsrc, zip_read_rsrc *, zip_entry, -1, le_zip_entry_name, le_zip_entry);
- ZEND_FETCH_RESOURCE(z_rsrc, zip_rsrc *, zip, -1, le_zip_dir_name, le_zip_dir);
+ if ((zr_rsrc = (zip_read_rsrc *)zend_fetch_resource(Z_RES_P(zip_entry), le_zip_entry_name, le_zip_entry)) == NULL) {
+ RETURN_FALSE;
+ }
+
+ if ((z_rsrc = (zip_rsrc *)zend_fetch_resource(Z_RES_P(zip), le_zip_dir_name, le_zip_dir)) == NULL) {
+ RETURN_FALSE;
+ }
if (zr_rsrc->zf != NULL) {
RETURN_TRUE;
@@ -1233,7 +1243,9 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_close)
return;
}
- ZEND_FETCH_RESOURCE(zr_rsrc, zip_read_rsrc *, zip_entry, -1, le_zip_entry_name, le_zip_entry);
+ if ((zr_rsrc = (zip_read_rsrc *)zend_fetch_resource(Z_RES_P(zip_entry), le_zip_entry_name, le_zip_entry)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_BOOL(SUCCESS == zend_list_close(Z_RES_P(zip_entry)));
}
@@ -1253,7 +1265,9 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_read)
return;
}
- ZEND_FETCH_RESOURCE(zr_rsrc, zip_read_rsrc *, zip_entry, -1, le_zip_entry_name, le_zip_entry);
+ if ((zr_rsrc = (zip_read_rsrc *)zend_fetch_resource(Z_RES_P(zip_entry), le_zip_entry_name, le_zip_entry)) == NULL) {
+ RETURN_FALSE;
+ }
if (len <= 0) {
len = 1024;
@@ -1285,7 +1299,9 @@ static void php_zip_entry_get_info(INTERNAL_FUNCTION_PARAMETERS, int opt) /* {{{
return;
}
- ZEND_FETCH_RESOURCE(zr_rsrc, zip_read_rsrc *, zip_entry, -1, le_zip_entry_name, le_zip_entry);
+ if ((zr_rsrc = (zip_read_rsrc *)zend_fetch_resource(Z_RES_P(zip_entry), le_zip_entry_name, le_zip_entry)) == NULL) {
+ RETURN_FALSE;
+ }
if (!zr_rsrc->zf) {
RETURN_FALSE;