Skip to content

Use zend_long for resource ID #7436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -2166,7 +2166,9 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_cannot_add_element(vo

ZEND_API ZEND_COLD void ZEND_FASTCALL zend_use_resource_as_offset(const zval *dim)
{
zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
zend_error(E_WARNING,
"Resource ID#" ZEND_LONG_FMT " used as offset, casting to integer (" ZEND_LONG_FMT ")",
Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
}

static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_new_element_for_string(void)
Expand Down
5 changes: 2 additions & 3 deletions Zend/zend_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ static HashTable list_destructors;

ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type)
{
int index;
zval zv;

index = zend_hash_next_free_element(&EG(regular_list));
zend_long index = zend_hash_next_free_element(&EG(regular_list));
if (index == 0) {
index = 1;
} else if (index == INT_MAX) {
} else if (index == ZEND_LONG_MAX) {
zend_error_noreturn(E_ERROR, "Resource ID space overflow");
}
ZVAL_NEW_RES(&zv, index, ptr, type);
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ struct _zend_object {

struct _zend_resource {
zend_refcounted_h gc;
int handle; // TODO: may be removed ???
zend_long handle; // TODO: may be removed ???
int type;
void *ptr;
};
Expand Down
2 changes: 1 addition & 1 deletion ext/oci8/oci8.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode)
descriptor = (php_oci_descriptor *) column->descid->ptr;

if (!descriptor) {
php_error_docref(NULL, E_WARNING, "Unable to find LOB descriptor #%d", column->descid->handle);
php_error_docref(NULL, E_WARNING, "Unable to find LOB descriptor #" ZEND_LONG_FMT, column->descid->handle);
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion ext/standard/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ PHPAPI PHP_FUNCTION(fclose)
PHP_STREAM_TO_ZVAL(stream, res);

if ((stream->flags & PHP_STREAM_FLAG_NO_FCLOSE) != 0) {
php_error_docref(NULL, E_WARNING, "%d is not a valid stream resource", stream->res->handle);
php_error_docref(NULL, E_WARNING, ZEND_LONG_FMT " is not a valid stream resource", stream->res->handle);
RETURN_FALSE;
}

Expand Down
4 changes: 2 additions & 2 deletions ext/standard/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */
}
case IS_RESOURCE: {
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(struc));
php_printf("%sresource(%d) of type (%s)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown");
php_printf("%sresource(" ZEND_LONG_FMT ") of type (%s)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown");
break;
}
case IS_REFERENCE:
Expand Down Expand Up @@ -380,7 +380,7 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level) /* {{{ */
break;
case IS_RESOURCE: {
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(struc));
php_printf("resource(%d) of type (%s) refcount(%u)\n", Z_RES_P(struc)->handle, type_name ? type_name : "Unknown", Z_REFCOUNT_P(struc));
php_printf("resource(" ZEND_LONG_FMT ") of type (%s) refcount(%u)\n", Z_RES_P(struc)->handle, type_name ? type_name : "Unknown", Z_REFCOUNT_P(struc));
break;
}
case IS_REFERENCE:
Expand Down
2 changes: 1 addition & 1 deletion sapi/phpdbg/phpdbg_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ char *phpdbg_short_zval_print(zval *zv, int maxlen) /* {{{ */
zend_string_release(str);
} break;
case IS_RESOURCE:
spprintf(&decode, 0, "Rsrc #%d", Z_RES_HANDLE_P(zv));
spprintf(&decode, 0, "Rsrc #" ZEND_LONG_FMT, Z_RES_HANDLE_P(zv));
break;
case IS_ARRAY:
spprintf(&decode, 0, "array(%d)", zend_hash_num_elements(Z_ARR_P(zv)));
Expand Down