]> granicus.if.org Git - php/commitdiff
fix leak and check for < 0 only of the 5th arg was passed
authorAntony Dovgal <tony2001@php.net>
Fri, 18 May 2007 20:34:13 +0000 (20:34 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 18 May 2007 20:34:13 +0000 (20:34 +0000)
ext/standard/file.c

index 1b61f17804b9ffc8f0ea37f07ebe31fa2bbee866..870972b3669a276dd2f57e232655a1ce1f2e1c11 100644 (file)
@@ -536,6 +536,11 @@ PHP_FUNCTION(file_get_contents)
                return;
        }
 
+       if (ZEND_NUM_ARGS() == 5 && maxlen < 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "length must be greater than or equal to zero");
+               RETURN_FALSE;
+       }
+
        context = php_stream_context_from_zval(zcontext, 0);
 
        stream = php_stream_open_wrapper_ex(filename, "rb", 
@@ -545,11 +550,6 @@ PHP_FUNCTION(file_get_contents)
                RETURN_FALSE;
        }
 
-       if (maxlen < 0) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to zero");
-               RETURN_FALSE;
-       }
-
        if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset);
                php_stream_close(stream);