sander          Sun Oct  6 07:28:12 2002 EDT

  Modified files:              
    /php4/ext/standard  string.c 
  Log:
  Fixed segfault and memory leak in the new implementation of implode()
  
  
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.313 php4/ext/standard/string.c:1.314
--- php4/ext/standard/string.c:1.313    Fri Oct  4 16:44:19 2002
+++ php4/ext/standard/string.c  Sun Oct  6 07:28:11 2002
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: string.c,v 1.313 2002/10/04 20:44:19 sterling Exp $ */
+/* $Id: string.c,v 1.314 2002/10/06 11:28:11 sander Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
@@ -825,6 +825,10 @@
 
        numelems = zend_hash_num_elements(Z_ARRVAL_P(arr));
 
+       if(numelems == 0) {
+               RETURN_EMPTY_STRING();
+       }
+
        zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos);
        while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), 
                                                                                 (void 
**) &tmp,
@@ -888,6 +892,8 @@
        zval_ptr_dtor(arg1);
        if (arg2) {
                zval_ptr_dtor(arg2);
+       } else {
+               FREE_ZVAL(delim);
        }
 }
 /* }}} */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to