RETURN_FALSE;
}
- if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) {
-
- if (PG(magic_quotes_runtime)) {
+ len = php_stream_copy_to_mem(stream, &contents, maxlen, 0);
+
+ if (contents) {
+ if (len && 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;
+ RETVAL_EMPTY_STRING();
}
}
/* }}} */
--- /dev/null
+--TEST--
+stream_get_contents() - Testing offset out of range
+--FILE--
+<?php
+
+$tmp = tmpfile();
+
+fwrite($tmp, "12345");
+
+echo stream_get_contents($tmp, 2, 5), "--\n";
+echo stream_get_contents($tmp, 2), "--\n";
+echo stream_get_contents($tmp, 2, 3), "--\n";
+echo stream_get_contents($tmp, 2, -1), "--\n";
+
+@unlink($tmp);
+
+?>
+--EXPECT--
+--
+--
+45--
+--