diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-25 13:03:26 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-25 13:03:26 +0100 |
commit | d5ff57477b82070873467d16e1e6ac8d0c8621c0 (patch) | |
tree | bc353ca42e52c7727470c5559b6ed083bb0b983f | |
parent | 9489a7bfdb1ee83bbac73a125d5aa1ab6b5b7616 (diff) | |
parent | a8daef51e1f070d2ccd331f4206df71cea3bce83 (diff) | |
download | php-git-d5ff57477b82070873467d16e1e6ac8d0c8621c0.tar.gz |
Merge branch 'PHP-7.4'
-rw-r--r-- | Zend/tests/exception_getters_with_ref_props.phpt | 30 | ||||
-rw-r--r-- | Zend/zend_exceptions.c | 36 |
2 files changed, 54 insertions, 12 deletions
diff --git a/Zend/tests/exception_getters_with_ref_props.phpt b/Zend/tests/exception_getters_with_ref_props.phpt new file mode 100644 index 0000000000..d3dcd8326f --- /dev/null +++ b/Zend/tests/exception_getters_with_ref_props.phpt @@ -0,0 +1,30 @@ +--TEST-- +Calling exception getters when properties hold references +--FILE-- +<?php + +class MyException extends Exception { + public function __construct(&$refMsg, &$refCode, &$refFile, &$refLine) { + $this->message =& $refMsg; + $this->code =& $refCode; + $this->file =& $refFile; + $this->line =& $refLine; + } +} + +$refMsg = "foo"; +$refCode = 0; +$refFile = "foobar"; +$refLine = 42; +$ex = new MyException($refMsg, $refCode, $refFile, $refLine); +var_dump($ex->getMessage()); +var_dump($ex->getCode()); +var_dump($ex->getFile()); +var_dump($ex->getLine()); + +?> +--EXPECT-- +string(3) "foo" +int(0) +string(6) "foobar" +int(42) diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 2f59d91953..f758b96bf9 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -400,11 +400,13 @@ ZEND_METHOD(error_exception, __construct) Get the file in which the exception occurred */ ZEND_METHOD(exception, getFile) { - zval rv; + zval *prop, rv; DEFAULT_0_PARAMS; - ZVAL_COPY(return_value, GET_PROPERTY(ZEND_THIS, ZEND_STR_FILE)); + prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_FILE); + ZVAL_DEREF(prop); + ZVAL_COPY(return_value, prop); } /* }}} */ @@ -412,11 +414,13 @@ ZEND_METHOD(exception, getFile) Get the line in which the exception occurred */ ZEND_METHOD(exception, getLine) { - zval rv; + zval *prop, rv; DEFAULT_0_PARAMS; - ZVAL_COPY(return_value, GET_PROPERTY(ZEND_THIS, ZEND_STR_LINE)); + prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_LINE); + ZVAL_DEREF(prop); + ZVAL_COPY(return_value, prop); } /* }}} */ @@ -424,11 +428,13 @@ ZEND_METHOD(exception, getLine) Get the exception message */ ZEND_METHOD(exception, getMessage) { - zval rv; + zval *prop, rv; DEFAULT_0_PARAMS; - ZVAL_COPY(return_value, GET_PROPERTY(ZEND_THIS, ZEND_STR_MESSAGE)); + prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_MESSAGE); + ZVAL_DEREF(prop); + ZVAL_COPY(return_value, prop); } /* }}} */ @@ -436,11 +442,13 @@ ZEND_METHOD(exception, getMessage) Get the exception code */ ZEND_METHOD(exception, getCode) { - zval rv; + zval *prop, rv; DEFAULT_0_PARAMS; - ZVAL_COPY(return_value, GET_PROPERTY(ZEND_THIS, ZEND_STR_CODE)); + prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_CODE); + ZVAL_DEREF(prop); + ZVAL_COPY(return_value, prop); } /* }}} */ @@ -448,11 +456,13 @@ ZEND_METHOD(exception, getCode) Get the stack trace for the location in which the exception occurred */ ZEND_METHOD(exception, getTrace) { - zval rv; + zval *prop, rv; DEFAULT_0_PARAMS; - ZVAL_COPY(return_value, GET_PROPERTY(ZEND_THIS, ZEND_STR_TRACE)); + prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_TRACE); + ZVAL_DEREF(prop); + ZVAL_COPY(return_value, prop); } /* }}} */ @@ -460,11 +470,13 @@ ZEND_METHOD(exception, getTrace) Get the exception severity */ ZEND_METHOD(error_exception, getSeverity) { - zval rv; + zval *prop, rv; DEFAULT_0_PARAMS; - ZVAL_COPY(return_value, GET_PROPERTY(ZEND_THIS, ZEND_STR_SEVERITY)); + prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_SEVERITY); + ZVAL_DEREF(prop); + ZVAL_COPY(return_value, prop); } /* }}} */ |