[PATCH] gcov: check return code of a fclose

Martin Liška mliska@suse.cz
Wed Aug 4 15:27:34 GMT 2021


We miss a place where I/O write error can occur.

Pushed to master as obvious.

Martin

gcc/ChangeLog:

	PR gcov-profile/101773
	* gcov-io.c (gcov_close): Check return code of a fclose.
---
  gcc/gcov-io.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index 4b1e11d4530..7819593234a 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -199,7 +199,9 @@ gcov_close (void)
  {
    if (gcov_var.file)
      {
-      fclose (gcov_var.file);
+      if (fclose (gcov_var.file))
+	gcov_var.error = 1;
+
        gcov_var.file = 0;
      }
    gcov_var.mode = 0;
-- 
2.32.0



More information about the Gcc-patches mailing list