]> granicus.if.org Git - php/commitdiff
fix segfault in file_set_contents() when the file could not successfully
authorSterling Hughes <sterling@php.net>
Fri, 21 Mar 2003 22:22:15 +0000 (22:22 +0000)
committerSterling Hughes <sterling@php.net>
Fri, 21 Mar 2003 22:22:15 +0000 (22:22 +0000)
be opened.

ext/standard/file.c

index 138b723fd4069789a5ea7bb73810b41dc9fb2124..b6d3779d064d821f937bbfbd4ef810f064e60fc5 100644 (file)
@@ -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) {