summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-05-18 20:34:13 +0000
committerAntony Dovgal <tony2001@php.net>2007-05-18 20:34:13 +0000
commit7e80ad9407b0a35ab9ae14218e07f0c2cdb7a6b7 (patch)
tree118deea1c6c500ce76e0f8e97141727fd93b1bda
parentcfedafff67b6edae0370717705550b75e2cb5a3c (diff)
downloadphp-git-7e80ad9407b0a35ab9ae14218e07f0c2cdb7a6b7.tar.gz
fix leak and check for < 0 only of the 5th arg was passed
-rw-r--r--ext/standard/file.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 1b61f17804..870972b366 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -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);