From ee08a9e1b045e8d2f4f13a0e60c2f603b66b0d69 Mon Sep 17 00:00:00 2001 From: Marc Payne Date: Mon, 6 Jul 2015 02:51:43 -0600 Subject: [PATCH] Close file only if it was successfully opened If BUILD_IPV6=ON (default), but the user has disabled ipv6 support in the kernel using the parameter ipv6.disable=1, then conky fails to open /proc/net/if_inet6. This leads to a segfault when conky calls fclose(file) regardless. This fix simply moves the fclose call into the preceding if statement. --- src/linux.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linux.cc b/src/linux.cc index 847acacc..7977fee8 100644 --- a/src/linux.cc +++ b/src/linux.cc @@ -643,8 +643,8 @@ int update_net_stats(void) } lastv6->next = NULL; } + fclose(file); } - fclose(file); #endif /* BUILD_IPV6 */ first = 0;