]> 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:07 +0000 (20:34 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 18 May 2007 20:34:07 +0000 (20:34 +0000)
ext/standard/file.c

index 66bca30904f5ff6f7dcff405b134c8775a82dd5a..1f81380c292059761b1c5304890572a5a00d9013 100644 (file)
@@ -554,6 +554,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);
        if (php_stream_path_param_encode(ppfilename, &filename, &filename_len, REPORT_ERRORS, context) == FAILURE) {
                RETURN_FALSE;
@@ -566,11 +571,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);