Hi all,

My name is Ilia--I figured that since this is my first patch to the PHP
core, I should refrain from submitting a massive patch and keep it simple.
The patch that I have attached fixes a simple compiler warning within
Zend/zend_execute.c.

The compiler was complaining about comparing signed and unsigned integers.
What I did was wrap the whole block in an if statement that first ensures
that the signed integer in the comparison is greater than or equal to 0 and
then casts it to unsigned and actually does the comparison.  Since the
actual comparison logic is checking to see that an unsigned integer is
larger than the one I am casting, this is all safe.

Also, the entire test suite runs fine and the output is unchanged.  All in
all, I am confident with it.

After having used PHP for so many years, I'm really excited about finally
having found the time to apply my C knowledge and actually start
contributing back to the project :)

Thanks!

Ilia
Index: zend_execute.c
===================================================================
RCS file: /repository/ZendEngine2/zend_execute.c,v
retrieving revision 1.716.2.12.2.24.2.36
diff -u -b -r1.716.2.12.2.24.2.36 zend_execute.c
--- zend_execute.c      15 Aug 2008 19:47:23 -0000      1.716.2.12.2.24.2.36
+++ zend_execute.c      23 Sep 2008 04:23:24 -0000
@@ -626,7 +626,9 @@
                        return 0;
                }
 
-               if (T->str_offset.offset >= Z_STRLEN_P(T->str_offset.str)) {
+               if (Z_STRLEN_P(T->str_offset.str) >= 0)
+               {
+                       if (T->str_offset.offset >= (unsigned int) 
Z_STRLEN_P(T->str_offset.str)) {
                        Z_STRVAL_P(T->str_offset.str) = (char *) 
erealloc(Z_STRVAL_P(T->str_offset.str), T->str_offset.offset+1+1);
                        memset(Z_STRVAL_P(T->str_offset.str) + 
Z_STRLEN_P(T->str_offset.str),
                               ' ',
@@ -634,6 +636,7 @@
                        Z_STRVAL_P(T->str_offset.str)[T->str_offset.offset+1] = 
0;
                        Z_STRLEN_P(T->str_offset.str) = T->str_offset.offset+1;
                }
+               }
 
                if (Z_TYPE_P(value) != IS_STRING) {
                        zval tmp = *value;
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to