felipe                                   Sun, 20 Feb 2011 16:33:53 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=308504

Log:
- Fixed memory leak in DirectoryIterator::getExtension() and 
SplFileInfo::getExtension()

Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c
    U   php/php-src/trunk/ext/spl/spl_directory.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2011-02-20 16:09:50 UTC (rev 308503)
+++ php/php-src/branches/PHP_5_3/NEWS   2011-02-20 16:33:53 UTC (rev 308504)
@@ -5,9 +5,13 @@
   . Fixed bug #43512 (same parameter name can be used multiple times in
     method/function definition). (Felipe)

-- Exif extension
-  . Fixed bug #54002 (crash on crafted tag, reported by Luca Carettoni). 
(Pierre). (CVE-2011-0708)
+- Exif extension:
+  . Fixed bug #54002 (crash on crafted tag, reported by Luca Carettoni). 
(Pierre)
+    (CVE-2011-0708)

+- SPL extension:
+  . Fixed memory leak in DirectoryIterator::getExtension() and
+    SplFileInfo::getExtension(). (Felipe)
 17 Feb 2011, PHP 5.3.6RC1
 - Upgraded bundled Sqlite3 to version 3.7.4. (Ilia)
 - Upgraded bundled PCRE to version 8.11. (Ilia)

Modified: php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c        2011-02-20 
16:09:50 UTC (rev 308503)
+++ php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c        2011-02-20 
16:33:53 UTC (rev 308504)
@@ -854,7 +854,8 @@
 SPL_METHOD(SplFileInfo, getExtension)
 {
        spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-       char *fname, *p;
+       char *fname = NULL;
+       const char *p;
        size_t flen;
        int path_len, idx;

@@ -877,10 +878,15 @@
        p = zend_memrchr(fname, '.', flen);
        if (p) {
                idx = p - fname;
-               RETURN_STRINGL(fname + idx + 1, flen - idx - 1, 1);
+               RETVAL_STRINGL(fname + idx + 1, flen - idx - 1, 1);
+               efree(fname);
+               return;
+       } else {
+               if (fname) {
+                       efree(fname);
+               }
+               RETURN_EMPTY_STRING();
        }
-
-       RETURN_EMPTY_STRING();
 }
 /* }}}*/

@@ -889,7 +895,8 @@
 SPL_METHOD(DirectoryIterator, getExtension)
 {
        spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-       char *fname, *p;
+       char *fname = NULL;
+       const char *p;
        size_t flen;
        int idx;

@@ -902,10 +909,15 @@
        p = zend_memrchr(fname, '.', flen);
        if (p) {
                idx = p - fname;
-               RETURN_STRINGL(fname + idx + 1, flen - idx - 1, 1);
+               RETVAL_STRINGL(fname + idx + 1, flen - idx - 1, 1);
+               efree(fname);
+               return;
+       } else {
+               if (fname) {
+                       efree(fname);
+               }
+               RETURN_EMPTY_STRING();
        }
-
-       RETURN_EMPTY_STRING();
 }
 /* }}} */


Modified: php/php-src/trunk/ext/spl/spl_directory.c
===================================================================
--- php/php-src/trunk/ext/spl/spl_directory.c   2011-02-20 16:09:50 UTC (rev 
308503)
+++ php/php-src/trunk/ext/spl/spl_directory.c   2011-02-20 16:33:53 UTC (rev 
308504)
@@ -857,7 +857,8 @@
 SPL_METHOD(SplFileInfo, getExtension)
 {
        spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-       char *fname, *p;
+       char *fname = NULL;
+       const char *p;
        size_t flen;
        int path_len, idx;

@@ -880,10 +881,15 @@
        p = zend_memrchr(fname, '.', flen);
        if (p) {
                idx = p - fname;
-               RETURN_STRINGL(fname + idx + 1, flen - idx - 1, 1);
+               RETVAL_STRINGL(fname + idx + 1, flen - idx - 1, 1);
+               efree(fname);
+               return;
+       } else {
+               if (fname) {
+                       efree(fname);
+               }
+               RETURN_EMPTY_STRING();
        }
-
-       RETURN_EMPTY_STRING();
 }
 /* }}}*/

@@ -892,7 +898,8 @@
 SPL_METHOD(DirectoryIterator, getExtension)
 {
        spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-       char *fname, *p;
+       char *fname = NULL;
+       const char *p;
        size_t flen;
        int idx;

@@ -905,10 +912,15 @@
        p = zend_memrchr(fname, '.', flen);
        if (p) {
                idx = p - fname;
-               RETURN_STRINGL(fname + idx + 1, flen - idx - 1, 1);
+               RETVAL_STRINGL(fname + idx + 1, flen - idx - 1, 1);
+               efree(fname);
+               return;
+       } else {
+               if (fname) {
+                       efree(fname);
+               }
+               RETURN_EMPTY_STRING();
        }
-
-       RETURN_EMPTY_STRING();
 }
 /* }}} */


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

Reply via email to