diff options
| author | Dmitry Stogov <dmitry@zend.com> | 2016-12-02 12:34:46 +0300 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@zend.com> | 2016-12-02 12:34:46 +0300 |
| commit | 67d90a4870499f53faefc3314f50181d4150d7d0 (patch) | |
| tree | 55b8880f0209ab442cb345f5cb9a6e1aef03f18b /Zend/zend_operators.c | |
| parent | fcaccbaa22784084d2cb59821b4e66c230702851 (diff) | |
| download | php-git-67d90a4870499f53faefc3314f50181d4150d7d0.tar.gz | |
Fixed possible memory leak in &=, |=, ^=.
Diffstat (limited to 'Zend/zend_operators.c')
| -rw-r--r-- | Zend/zend_operators.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index a02551b1bd..2d7fd96279 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1349,6 +1349,9 @@ ZEND_API int ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op if (EXPECTED(Z_STRLEN_P(op1) >= Z_STRLEN_P(op2))) { if (EXPECTED(Z_STRLEN_P(op1) == Z_STRLEN_P(op2)) && Z_STRLEN_P(op1) == 1) { zend_uchar or = (zend_uchar) (*Z_STRVAL_P(op1) | *Z_STRVAL_P(op2)); + if (result==op1) { + zend_string_release(Z_STR_P(result)); + } if (CG(one_char_string)[or]) { ZVAL_INTERNED_STR(result, CG(one_char_string)[or]); } else { @@ -1416,6 +1419,9 @@ ZEND_API int ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *o if (EXPECTED(Z_STRLEN_P(op1) >= Z_STRLEN_P(op2))) { if (EXPECTED(Z_STRLEN_P(op1) == Z_STRLEN_P(op2)) && Z_STRLEN_P(op1) == 1) { zend_uchar and = (zend_uchar) (*Z_STRVAL_P(op1) & *Z_STRVAL_P(op2)); + if (result==op1) { + zend_string_release(Z_STR_P(result)); + } if (CG(one_char_string)[and]) { ZVAL_INTERNED_STR(result, CG(one_char_string)[and]); } else { @@ -1483,6 +1489,9 @@ ZEND_API int ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *o if (EXPECTED(Z_STRLEN_P(op1) >= Z_STRLEN_P(op2))) { if (EXPECTED(Z_STRLEN_P(op1) == Z_STRLEN_P(op2)) && Z_STRLEN_P(op1) == 1) { zend_uchar xor = (zend_uchar) (*Z_STRVAL_P(op1) ^ *Z_STRVAL_P(op2)); + if (result==op1) { + zend_string_release(Z_STR_P(result)); + } if (CG(one_char_string)[xor]) { ZVAL_INTERNED_STR(result, CG(one_char_string)[xor]); } else { |
