From 8c99b65c4d2bc91aff7efce6f88713ebcb5d55c5 Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Sat, 13 Dec 2014 21:11:09 +0000 Subject: [PATCH] Fixed memory leak introduced by 73458e8f --- Zend/tests/self_and.phpt | 25 +++++++++++++++++++++++++ Zend/tests/self_mod.phpt | 25 +++++++++++++++++++++++++ Zend/tests/self_or.phpt | 25 +++++++++++++++++++++++++ Zend/tests/self_xor.phpt | 25 +++++++++++++++++++++++++ Zend/zend_operators.c | 18 ++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 Zend/tests/self_and.phpt create mode 100644 Zend/tests/self_mod.phpt create mode 100644 Zend/tests/self_or.phpt create mode 100644 Zend/tests/self_xor.phpt diff --git a/Zend/tests/self_and.phpt b/Zend/tests/self_and.phpt new file mode 100644 index 0000000000..cdcde77992 --- /dev/null +++ b/Zend/tests/self_and.phpt @@ -0,0 +1,25 @@ +--TEST-- +ANDing strings +--FILE-- + +--EXPECTF-- +int(18) +int(0) +int(33) +Done diff --git a/Zend/tests/self_mod.phpt b/Zend/tests/self_mod.phpt new file mode 100644 index 0000000000..19e45d88fc --- /dev/null +++ b/Zend/tests/self_mod.phpt @@ -0,0 +1,25 @@ +--TEST-- +Moduloing strings +--FILE-- + +--EXPECTF-- +int(13) +int(0) +int(3) +Done diff --git a/Zend/tests/self_or.phpt b/Zend/tests/self_or.phpt new file mode 100644 index 0000000000..ae667bff16 --- /dev/null +++ b/Zend/tests/self_or.phpt @@ -0,0 +1,25 @@ +--TEST-- +ORing strings +--FILE-- + +--EXPECTF-- +int(127) +int(11) +int(45345) +Done diff --git a/Zend/tests/self_xor.phpt b/Zend/tests/self_xor.phpt new file mode 100644 index 0000000000..a7e43f539d --- /dev/null +++ b/Zend/tests/self_xor.phpt @@ -0,0 +1,25 @@ +--TEST-- +XORing strings +--FILE-- + +--EXPECTF-- +int(109) +int(11) +int(45312) +Done diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index bdb4ea8861..b43c672526 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1162,6 +1162,9 @@ ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * return SUCCESS; } + if (op1 == result) { + zval_dtor(result); + } ZVAL_LONG(result, op1_lval % op2_lval); return SUCCESS; } @@ -1324,6 +1327,9 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) / op2_lval = Z_LVAL_P(op2); } + if (op1 == result) { + zval_dtor(result); + } ZVAL_LONG(result, op1_lval | op2_lval); return SUCCESS; } @@ -1379,6 +1385,9 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) op2_lval = Z_LVAL_P(op2); } + if (op1 == result) { + zval_dtor(result); + } ZVAL_LONG(result, op1_lval & op2_lval); return SUCCESS; } @@ -1434,6 +1443,9 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) op2_lval = Z_LVAL_P(op2); } + if (op1 == result) { + zval_dtor(result); + } ZVAL_LONG(result, op1_lval ^ op2_lval); return SUCCESS; } @@ -1486,6 +1498,9 @@ ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) / } } + if (op1 == result) { + zval_dtor(result); + } ZVAL_LONG(result, op1_lval << op2_lval); return SUCCESS; } @@ -1538,6 +1553,9 @@ ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) } } + if (op1 == result) { + zval_dtor(result); + } ZVAL_LONG(result, op1_lval >> op2_lval); return SUCCESS; } -- 2.40.0