tony2001                Thu Apr  6 19:01:56 2006 UTC

  Modified files:              (Branch: PHP_5_1)
    /php-src/ext/spl    spl_directory.c 
    /php-src    NEWS 
  Log:
  fix #36981 (SplFileObject->fgets() ignores max_length)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.45.2.26&r2=1.45.2.27&diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.45.2.26 
php-src/ext/spl/spl_directory.c:1.45.2.27
--- php-src/ext/spl/spl_directory.c:1.45.2.26   Wed Mar 29 14:28:42 2006
+++ php-src/ext/spl/spl_directory.c     Thu Apr  6 19:01:56 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c,v 1.45.2.26 2006/03/29 14:28:42 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.45.2.27 2006/04/06 19:01:56 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -1327,7 +1327,7 @@
 static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent 
TSRMLS_DC) /* {{{ */
 {
        char *buf;
-       size_t line_len;
+       size_t line_len = 0;
        int len;
        long line_add = (intern->u.file.current_line || 
intern->u.file.current_zval) ? 1 : 0;
 
@@ -1340,7 +1340,17 @@
                return FAILURE;
        }
 
-       buf = php_stream_get_line(intern->u.file.stream, NULL, 
intern->u.file.max_line_len, &line_len);
+       if (intern->u.file.max_line_len > 0) {
+               buf = emalloc((intern->u.file.max_line_len + 1) * sizeof(char));
+               if (php_stream_get_line(intern->u.file.stream, buf, 
intern->u.file.max_line_len, &line_len) == NULL) {
+                       efree(buf);
+                       buf = NULL;
+               } else {
+                       buf[line_len] = '\0';
+               }
+       } else {
+               buf = php_stream_get_line(intern->u.file.stream, NULL, 0, 
&line_len);
+       }
 
        if (!buf) {
                intern->u.file.current_line = estrdup("");
http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2027.2.496&r2=1.2027.2.497&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.496 php-src/NEWS:1.2027.2.497
--- php-src/NEWS:1.2027.2.496   Thu Apr  6 02:39:55 2006
+++ php-src/NEWS        Thu Apr  6 19:01:56 2006
@@ -15,6 +15,7 @@
 - Removed the E_STRICT deprecation notice from "var". (Ilia)
 - Fixed debug_zval_dump() to support private and protected members. (Dmitry)
 - Fixed SoapFault::getMessage(). (Dmitry)
+- Fixed bug #36981 (SplFileObject->fgets() ignores max_length). (Tony)
 - Fixed bug #36957 (serialize() does not handle recursion). (Ilia)
 - Fixed bug #36944 (strncmp & strncasecmp do not return false on negative 
   string length). (Tony)

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

Reply via email to