]> granicus.if.org Git - php/commitdiff
- Fixed problem when using uninitialized values in comparisons with strings.
authorAndi Gutmans <andi@php.net>
Sat, 10 Jun 2000 14:39:06 +0000 (14:39 +0000)
committerAndi Gutmans <andi@php.net>
Sat, 10 Jun 2000 14:39:06 +0000 (14:39 +0000)
-  They behave as empty strings again just like in PHP 3.

Zend/zend_operators.c

index 30d7e3747e602593647b65d1a0d340e2c5b8797a..cfa40d50bc6c25572f796a31edcf7f6d3223d6a1 100644 (file)
@@ -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;