From 390dccacac73e465dfb51f4d77362ac92bbb42a9 Mon Sep 17 00:00:00 2001 From: Andi Gutmans Date: Sat, 10 Jun 2000 14:39:06 +0000 Subject: [PATCH] - Fixed problem when using uninitialized values in comparisons with strings. - They behave as empty strings again just like in PHP 3. --- Zend/zend_operators.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 30d7e3747e..cfa40d50bc 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1047,6 +1047,19 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2) { zval op1_copy, op2_copy; + if ((op1->type == IS_NULL && op2->type == IS_STRING) + || (op2->type == IS_NULL && op1->type == IS_STRING)) { + if (op1->type == IS_NULL) { + result->type = IS_LONG; + result->value.lval = zend_binary_strcmp("", 0, op2->value.str.val, op2->value.str.len); + return SUCCESS; + } else { + result->type = IS_LONG; + result->value.lval = zend_binary_strcmp(op1->value.str.val, op1->value.str.len, "", 0); + return SUCCESS; + } + } + if (op1->type == IS_STRING && op2->type == IS_STRING) { zendi_smart_strcmp(result, op1, op2); return SUCCESS; -- 2.40.0