From 5e66299f1a9c9879bfb393f639c5827f72282dac Mon Sep 17 00:00:00 2001 From: kosako Date: Tue, 15 Nov 2016 13:21:40 +0900 Subject: [PATCH] check return value for fopen() #34 --- src/st.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/st.c b/src/st.c index 022880a..088afe5 100644 --- a/src/st.c +++ b/src/st.c @@ -130,11 +130,13 @@ static int collision = 0; static int init_st = 0; static void -stat_col() +stat_col(void) { - FILE *f = fopen("/tmp/col", "w"); - fprintf(f, "collision: %d\n", collision); - fclose(f); + FILE *f = fopen("/tmp/col", "w"); + if (f == 0) return ; + + fprintf(f, "collision: %d\n", collision); + fclose(f); } #endif -- 2.40.0