]> granicus.if.org Git - onig/commitdiff
check return value for fopen() #34
authorkosako <kosako@sofnec.co.jp>
Tue, 15 Nov 2016 04:21:40 +0000 (13:21 +0900)
committerkosako <kosako@sofnec.co.jp>
Tue, 15 Nov 2016 04:21:40 +0000 (13:21 +0900)
src/st.c

index 022880ae360a4eb18dee0562aeb73634c37ed2f5..088afe558da1810bd606e310528c2d87792e0532 100644 (file)
--- 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