Skip to content

Commit

Permalink
To display a resource handle we need to use ->handle, as we don't wan…
Browse files Browse the repository at this point in the history
…t to leak the pointer
  • Loading branch information
derickr committed Sep 5, 2015
1 parent 116b3a6 commit 2ea8135
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions xdebug_var.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ void xdebug_var_export(zval **struc, xdebug_str *str, int level, int debug_zval,

#if PHP_VERSION_ID >= 70000
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_RES_P(*struc) TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf("resource(%ld) of type (%s)", Z_RES_P(*struc), type_name ? type_name : "Unknown"), 1);
xdebug_str_add(str, xdebug_sprintf("resource(%ld) of type (%s)", Z_RES_P(*struc)->handle, type_name ? type_name : "Unknown"), 1);
#else
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_LVAL_P(*struc) TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf("resource(%ld) of type (%s)", Z_LVAL_P(*struc), type_name ? type_name : "Unknown"), 1);
Expand Down Expand Up @@ -1183,7 +1183,7 @@ static void xdebug_var_synopsis(zval **struc, xdebug_str *str, int level, int de

#if PHP_VERSION_ID >= 70000
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_RES_P(*struc) TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf("resource(%ld) of type (%s)", Z_RES_P(*struc), type_name ? type_name : "Unknown"), 1);
xdebug_str_add(str, xdebug_sprintf("resource(%ld) of type (%s)", Z_RES_P(*struc)->handle, type_name ? type_name : "Unknown"), 1);
#else
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_LVAL_P(*struc) TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf("resource(%ld) of type (%s)", Z_LVAL_P(*struc), type_name ? type_name : "Unknown"), 1);
Expand Down Expand Up @@ -1467,7 +1467,7 @@ void xdebug_var_export_text_ansi(zval **struc, xdebug_str *str, int mode, int le
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_RES_P(*struc) TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf("%sresource%s(%s%ld%s) of type (%s)",
ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF,
ANSI_COLOR_RESOURCE, Z_RES_P(*struc), ANSI_COLOR_RESET, type_name ? type_name : "Unknown"), 1);
ANSI_COLOR_RESOURCE, Z_RES_P(*struc)->handle, ANSI_COLOR_RESET, type_name ? type_name : "Unknown"), 1);
#else
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_LVAL_P(*struc) TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf("%sresource%s(%s%ld%s) of type (%s)",
Expand Down Expand Up @@ -1568,7 +1568,7 @@ static void xdebug_var_synopsis_text_ansi(zval **struc, xdebug_str *str, int mod

#if PHP_VERSION_ID >= 70000
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_RES_P(*struc) TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf("resource(%s%ld%s) of type (%s)", ANSI_COLOR_LONG, Z_RES_P(*struc), ANSI_COLOR_RESET, type_name ? type_name : "Unknown"), 1);
xdebug_str_add(str, xdebug_sprintf("resource(%s%ld%s) of type (%s)", ANSI_COLOR_LONG, Z_RES_P(*struc)->handle, ANSI_COLOR_RESET, type_name ? type_name : "Unknown"), 1);
#else
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_LVAL_P(*struc) TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf("resource(%s%ld%s) of type (%s)", ANSI_COLOR_LONG, Z_LVAL_P(*struc), ANSI_COLOR_RESET, type_name ? type_name : "Unknown"), 1);
Expand Down Expand Up @@ -2052,7 +2052,7 @@ void xdebug_var_export_xml_node(zval **struc, char *name, xdebug_xml_node *node,
xdebug_xml_add_attribute(node, "type", "resource");
#if PHP_VERSION_ID >= 70000
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_RES_P(*struc) TSRMLS_CC);
xdebug_xml_add_text(node, xdebug_sprintf("resource id='%ld' type='%s'", Z_RES_P(*struc), type_name ? type_name : "Unknown"));
xdebug_xml_add_text(node, xdebug_sprintf("resource id='%ld' type='%s'", Z_RES_P(*struc)->handle, type_name ? type_name : "Unknown"));
#else
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_LVAL_P(*struc) TSRMLS_CC);
xdebug_xml_add_text(node, xdebug_sprintf("resource id='%ld' type='%s'", Z_LVAL_P(*struc), type_name ? type_name : "Unknown"));
Expand Down Expand Up @@ -2333,10 +2333,11 @@ void xdebug_var_export_fancy(zval **struc, xdebug_str *str, int level, int debug

#if PHP_VERSION_ID >= 70000
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_RES_P(*struc) TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf("<b>resource</b>(<i>%ld</i><font color='%s'>,</font> <i>%s</i>)", Z_RES_P(*struc)->handle, COLOR_RESOURCE, type_name ? type_name : "Unknown"), 1);
#else
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_LVAL_P(*struc) TSRMLS_CC);
#endif
xdebug_str_add(str, xdebug_sprintf("<b>resource</b>(<i>%ld</i><font color='%s'>,</font> <i>%s</i>)", Z_LVAL_P(*struc), COLOR_RESOURCE, type_name ? type_name : "Unknown"), 1);
#endif
break;
}

Expand Down Expand Up @@ -2482,7 +2483,7 @@ static void xdebug_var_synopsis_fancy(zval **struc, xdebug_str *str, int level,

#if PHP_VERSION_ID >= 70000
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_RES_P(*struc) TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf("<font color='%s'>resource(%ld, %s)</font>", COLOR_RESOURCE, Z_RES_P(*struc), type_name ? type_name : "Unknown"), 1);
xdebug_str_add(str, xdebug_sprintf("<font color='%s'>resource(%ld, %s)</font>", COLOR_RESOURCE, Z_RES_P(*struc)->handle, type_name ? type_name : "Unknown"), 1);
#else
type_name = (char *) zend_rsrc_list_get_rsrc_type(Z_LVAL_P(*struc) TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf("<font color='%s'>resource(%ld, %s)</font>", COLOR_RESOURCE, Z_LVAL_P(*struc), type_name ? type_name : "Unknown"), 1);
Expand Down

0 comments on commit 2ea8135

Please sign in to comment.