From 0a4282eabff64fd15a1fa3ad6f8dc04daedf4eca Mon Sep 17 00:00:00 2001 From: Sterling Hughes Date: Fri, 21 Mar 2003 22:22:15 +0000 Subject: [PATCH] fix segfault in file_set_contents() when the file could not successfully be opened. --- ext/standard/file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/standard/file.c b/ext/standard/file.c index 138b723fd4..b6d3779d06 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -476,6 +476,10 @@ PHP_FUNCTION(file_set_contents) stream = php_stream_open_wrapper(filename, "wb", (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); + if (stream == NULL) { + RETURN_FALSE; + } + if (data_len) { numbytes = php_stream_write(stream, data, data_len); if (numbytes < 0) { -- 2.50.1