]> granicus.if.org Git - php/commitdiff
- Fix crash in exception handling (zend_exception_error(...) and
authorAndi Gutmans <andi@php.net>
Mon, 1 Mar 2004 13:29:45 +0000 (13:29 +0000)
committerAndi Gutmans <andi@php.net>
Mon, 1 Mar 2004 13:29:45 +0000 (13:29 +0000)
  zend_eval_string_ex() were buggy (Dmitry, Andi)

Zend/zend.c
Zend/zend_exceptions.c
Zend/zend_execute_API.c

index 316abaec9f26c338cbe3fbd9ac48d6b46498e365..4fc4fdcb214d4883cf3b9f3907d6ff780083dcdf 100644 (file)
@@ -1061,8 +1061,6 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
                                                }
                                        } else {
                                                zend_exception_error(EG(exception) TSRMLS_CC);
-                                               zval_ptr_dtor(&EG(exception));
-                                               EG(exception) = NULL;
                                        }
                                        efree(params);
                                        zval_ptr_dtor(&old_exception);
@@ -1072,8 +1070,6 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
                                        }
                                } else {
                                        zend_exception_error(EG(exception) TSRMLS_CC);
-                                       zval_ptr_dtor(&EG(exception));
-                                       EG(exception) = NULL;
                                }
                                if (retval == NULL && *EG(return_value_ptr_ptr) != NULL) {
                                        zval_ptr_dtor(EG(return_value_ptr_ptr));
index dd1f2c08bb27112c1d2ce3b714f8e68f01c6fc12..6254810a5ae6d93942eaafc4353deb679b6d3127 100644 (file)
@@ -508,12 +508,12 @@ static void zend_error_va(int type, const char *file, uint lineno, const char *f
        va_end(args);
 }
 
+/* This function doesn't return as it calls E_ERROR */
 ZEND_API void zend_exception_error(zval *exception TSRMLS_DC)
 {
        zend_class_entry *ce_exception = Z_OBJCE_P(exception);
        if (instanceof_function(ce_exception, default_exception_ce TSRMLS_CC)) {
                zval *str, *file, *line;
-               zval *old_exception = EG(exception);
 
                EG(exception) = NULL;
                
@@ -543,8 +543,6 @@ ZEND_API void zend_exception_error(zval *exception TSRMLS_DC)
                file = zend_read_property(default_exception_ce, exception, "file", sizeof("file")-1, 1 TSRMLS_CC);
                line = zend_read_property(default_exception_ce, exception, "line", sizeof("line")-1, 1 TSRMLS_CC);
 
-               EG(exception) = old_exception;
-
                zend_error_va(E_ERROR, Z_STRVAL_P(file), Z_LVAL_P(line), "Uncaught %s\n  thrown", Z_STRVAL_P(str));
        } else {
                zend_error(E_ERROR, "Uncaught exception '%s'", ce_exception->name);
index b9ae38b096e92ee23e1081daccc194c1044c6b52..8c4c48c034032eef93fab604cba51b1df7e652eb 100644 (file)
@@ -926,16 +926,10 @@ ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSR
 ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC)
 {
        int result;
-       zval *exception = EG(exception);
 
-       if (handle_exceptions) {
-               EG(exception) = NULL;
-       }
        result = zend_eval_string(str, retval_ptr, string_name TSRMLS_CC);
        if (handle_exceptions && EG(exception)) {
                zend_exception_error(EG(exception) TSRMLS_CC);
-               zval_ptr_dtor(&EG(exception));
-               EG(exception) = exception;
                result = FAILURE;
        }
        return result;