fix file descriptors leaking
Change-Id: Ie76d19b279972dfd4e78bfc5fe5a302bf23de13b
diff --git a/ip/iproute.c b/ip/iproute.c
index 711576e..16dee80 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -1028,6 +1028,7 @@
if ((write (flush_fd, (void *)buffer, len)) < len) {
fprintf (stderr, "Cannot flush routing cache\n");
+ close(flush_fd);
return -1;
}
close(flush_fd);
diff --git a/ip/iptunnel.c b/ip/iptunnel.c
index 3525fbb..7c682a7 100644
--- a/ip/iptunnel.c
+++ b/ip/iptunnel.c
@@ -421,6 +421,7 @@
if ((ptr = strchr(buf, ':')) == NULL ||
(*ptr++ = 0, sscanf(buf, "%s", name) != 1)) {
fprintf(stderr, "Wrong format of /proc/net/dev. Sorry.\n");
+ fclose(fp);
return -1;
}
if (sscanf(ptr, "%ld%ld%ld%ld%ld%ld%ld%*d%ld%ld%ld%ld%ld%ld%ld",
@@ -459,6 +460,7 @@
}
printf("\n");
}
+ fclose(fp);
return 0;
}
diff --git a/lib/rt_names.c b/lib/rt_names.c
index 52edfe3..89b1cc3 100644
--- a/lib/rt_names.c
+++ b/lib/rt_names.c
@@ -54,6 +54,7 @@
sscanf(p, "%d %s #", &id, namebuf) != 2) {
fprintf(stderr, "Database %s is corrupted at %s\n",
file, p);
+ fclose(fp);
return;
}
@@ -91,6 +92,7 @@
sscanf(p, "%d %s #", &id, namebuf) != 2) {
fprintf(stderr, "Database %s is corrupted at %s\n",
file, p);
+ fclose(fp);
return;
}