]> Kevux Git Server - fll/commitdiff
Update: check if stream exists before attempting to close stream.
authorKevin Day <thekevinday@gmail.com>
Sat, 26 Sep 2020 21:05:47 +0000 (16:05 -0500)
committerKevin Day <thekevinday@gmail.com>
Sat, 26 Sep 2020 21:05:47 +0000 (16:05 -0500)
level_0/f_file/c/file.c

index 076a59a9ca24dac1624598eea7e6202e7a8468c0..b72d0f0b21276c58d7fe13cb7c8a2d59f73c8ecc 100644 (file)
@@ -1875,7 +1875,7 @@ extern "C" {
       if (!file) return F_status_set_error(F_parameter);
     #endif // _di_level_0_parameter_checking_
 
-    if (!fclose(file->stream)) {
+    if (file->stream && !fclose(file->stream)) {
       if (errno == EACCES) return F_status_set_error(F_access_denied);
       if (errno == EAGAIN) return F_status_set_error(F_prohibited);
       if (errno == EBADF) return F_status_set_error(F_file_descriptor);