[xdebug-dev] xdebug xdebug/php_xdebug.h xdebug/xdebug.c - Fixed a crash bug when using eval() and xdebug.collect_includes enabled.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Tue, 7 Apr 2009 23:21:07 +0200

Date: Tue Apr 7 23:21:07 CEST 2009
User: Derick Rethans
Directory: xdebug

Log Message:
[4.00]
- Fixed a crash bug when using eval() and xdebug.collect_includes enabled.
#- Will not merge this to Xdebug 2.x as it's just too bloody much work.

Modified files:
           xdebug/php_xdebug.h (version: 1.147)
           xdebug/xdebug.c (version: 1.445)

[FILE: /xdebug/php_xdebug.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -r1.146 -r1.147
--- xdebug/php_xdebug.h:1.146 Thu Mar 05 13:38:52 2009 GMT
+++ xdebug/php_xdebug.h Tue Apr 07 19:21:07 2009 GMT
@@ -165,6 +165,7 @@
         long trace_format;
         char *tracefile_name;
         char *last_exception_trace;
+ char *last_eval_statement;
 
         /* variable dumping limitation settings */
         long display_max_children;

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.444
retrieving revision 1.445
diff -u -r1.444 -r1.445
--- xdebug/xdebug.c:1.444 Sat Mar 28 18:22:19 2009 GMT
+++ xdebug/xdebug.c Tue Apr 07 19:21:07 2009 GMT
@@ -432,6 +432,38 @@
     return ZEND_USER_OPCODE_DISPATCH;
 }
 
+static int xdebug_include_or_eval_handler(ZEND_OPCODE_HANDLER_ARGS)
+{
+ zend_op *opline = execute_data->opline;
+
+ if (Z_LVAL(opline->op2.u.constant) == ZEND_EVAL) {
+ zval *inc_filename;
+ zval tmp_inc_filename;
+ int is_var;
+ int tmp_len;
+
+ inc_filename = get_zval(execute_data, &opline->op1, execute_data->Ts, &is_var);
+
+ if (inc_filename->type != IS_STRING) {
+ tmp_inc_filename = *inc_filename;
+ zval_copy_ctor(&tmp_inc_filename);
+ convert_to_string(&tmp_inc_filename);
+ inc_filename = &tmp_inc_filename;
+ }
+
+ /* Now let's store this info */
+ if (XG(last_eval_statement)) {
+ efree(XG(last_eval_statement));
+ }
+ XG(last_eval_statement) = php_addcslashes(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename), &tmp_len, 0, "'\\\0..\37", 6 TSRMLS_CC);
+
+ if (inc_filename == &tmp_inc_filename) {
+ zval_dtor(&tmp_inc_filename);
+ }
+ }
+ return ZEND_USER_OPCODE_DISPATCH;
+}
+
 /* Needed for code coverage as Zend doesn't always add EXT_STMT when expected */
 #define XDEBUG_SET_OPCODE_OVERRIDE(f,oc) \
         zend_set_user_opcode_handler(oc, xdebug_##f##_handler);
@@ -662,6 +694,7 @@
         XDEBUG_SET_OPCODE_OVERRIDE(pre_inc_obj, ZEND_PRE_INC_OBJ);
         XDEBUG_SET_OPCODE_OVERRIDE(switch_free, ZEND_SWITCH_FREE);
         XDEBUG_SET_OPCODE_OVERRIDE(qm_assign, ZEND_QM_ASSIGN);
+ XDEBUG_SET_OPCODE_OVERRIDE(include_or_eval, ZEND_INCLUDE_OR_EVAL);
 
         XDEBUG_SET_OPCODE_OVERRIDE(silence, ZEND_BEGIN_SILENCE);
         XDEBUG_SET_OPCODE_OVERRIDE(silence, ZEND_END_SILENCE);
@@ -798,6 +831,7 @@
         XG(function_count) = 0;
         XG(active_symbol_table) = NULL;
         XG(last_exception_trace) = NULL;
+ XG(last_eval_statement) = NULL;
         XG(do_collect_errors) = 0;
         XG(collected_errors) = xdebug_llist_alloc(xdebug_collected_error_dtor);
         
@@ -933,6 +967,10 @@
                 xdfree(XG(last_exception_trace));
         }
 
+ if (XG(last_eval_statement)) {
+ efree(XG(last_eval_statement));
+ }
+
         xdebug_llist_destroy(XG(collected_errors), NULL);
 
         /* Reset var_dump and set_time_limit to the original function */
@@ -1132,7 +1170,7 @@
                 if (tmp->function.type == XFUNC_EVAL) {
                         int is_var;
 
- tmp->include_filename = xdebug_get_zval_value(get_zval(zdata, &zdata->opline->op1, zdata->Ts, &is_var), 0, NULL);
+ tmp->include_filename = xdebug_sprintf("'%s'", XG(last_eval_statement));
                 } else if (XG(collect_includes)) {
                         tmp->include_filename = xdstrdup(zend_get_executed_filename(TSRMLS_C));
                 }
Received on Tue Apr 07 2009 - 23:21:53 BST

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST