File php-CVE-2015-8876.patch of Package php5.openSUSE_Leap_42.1_Update
X-Git-Url: http://72.52.91.13:8000/?p=php-src.git;a=blobdiff_plain;f=Zend%2Fzend_exceptions.c;h=1a3ee8f434e4870677333aeb268503f2e0b20642;hp=06be9885d5aafdfc0eb0e15d9ed14553e27ed27d;hb=e488690d957fce0dbdabe619adbe314ada498215;hpb=c96d08b27226193dd51f2b50e84272235c6aaa69
Index: php-5.6.1/Zend/zend_exceptions.c
===================================================================
--- php-5.6.1.orig/Zend/zend_exceptions.c 2016-05-24 11:49:46.394167757 +0200
+++ php-5.6.1/Zend/zend_exceptions.c 2016-05-24 11:50:42.787075470 +0200
@@ -41,7 +41,7 @@ void zend_exception_set_previous(zval *e
if (exception == add_previous || !add_previous || !exception) {
return;
}
- if (Z_TYPE_P(add_previous) != IS_OBJECT && !instanceof_function(Z_OBJCE_P(add_previous), default_exception_ce TSRMLS_CC)) {
+ if (Z_TYPE_P(add_previous) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(add_previous), default_exception_ce TSRMLS_CC)) {
zend_error(E_ERROR, "Cannot set non exception as previous exception");
return;
}
@@ -674,7 +674,7 @@ ZEND_METHOD(exception, __toString)
exception = getThis();
ZVAL_STRINGL(&fname, "gettraceasstring", sizeof("gettraceasstring")-1, 1);
- while (exception && Z_TYPE_P(exception) == IS_OBJECT) {
+ while (exception && Z_TYPE_P(exception) == IS_OBJECT && instanceof_function(Z_OBJCE_P(exception), default_exception_ce TSRMLS_CC)) {
prev_str = str;
_default_exception_get_entry(exception, "message", sizeof("message")-1, &message TSRMLS_CC);
_default_exception_get_entry(exception, "file", sizeof("file")-1, &file TSRMLS_CC);
@@ -684,6 +684,7 @@ ZEND_METHOD(exception, __toString)
convert_to_string(&file);
convert_to_long(&line);
+ trace = NULL;
fci.size = sizeof(fci);
fci.function_table = &Z_OBJCE_P(exception)->function_table;
fci.function_name = &fname;
@@ -696,7 +697,7 @@ ZEND_METHOD(exception, __toString)
zend_call_function(&fci, NULL TSRMLS_CC);
- if (Z_TYPE_P(trace) != IS_STRING) {
+ if (trace && Z_TYPE_P(trace) != IS_STRING) {
zval_ptr_dtor(&trace);
trace = NULL;
}