summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2003-05-14 01:08:47 +0000
committerSascha Schumann <sas@php.net>2003-05-14 01:08:47 +0000
commit862edc6aaefafd58394804771a0fabc4230bd7d1 (patch)
tree07fc0ffe296c2c5a28ef8c3323ea4bda5e1f136e
parentfcffe5b5821131dd3a1ccc851d0b3f8f42b70262 (diff)
downloadphp-git-862edc6aaefafd58394804771a0fabc4230bd7d1.tar.gz
Fix file_get_contents segfault on empty file
-rw-r--r--ext/standard/file.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 35691a34e9..66bc863005 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -434,14 +434,15 @@ PHP_FUNCTION(file_get_contents)
}
/* uses mmap if possible */
- if ((len = php_stream_copy_to_mem(stream, &contents, PHP_STREAM_COPY_ALL, 0)) >= 0) {
-
+ if ((len = php_stream_copy_to_mem(stream, &contents, PHP_STREAM_COPY_ALL, 0)) > 0) {
if (PG(magic_quotes_runtime)) {
contents = php_addslashes(contents, len, &newlen, 1 TSRMLS_CC); /* 1 = free source string */
len = newlen;
}
RETVAL_STRINGL(contents, len, 0);
+ } else if (len == 0) {
+ RETVAL_EMPTY_STRING();
} else {
RETVAL_FALSE;
}