ip-up-vpn: Fix resource leaks in error cases
These leaks aren't really consequential since this is a standalone command, and these "leaks" are in main(). But by putting in simple fixes for these, we reduce the noise when using static analysis to find leaks in Android code. Test: TreeHugger Change-Id: I2cbb4585c6c8d59a0eb89a72f17dfc4fbc532249
This commit is contained in:
parent
3e167da916
commit
e740353f0a
1 changed files with 4 additions and 0 deletions
|
@ -95,6 +95,7 @@ int main(int argc, char **argv)
|
|||
strncpy(ifr.ifr_name, interface, IFNAMSIZ);
|
||||
if (ioctl(s, SIOCSIFFLAGS, &ifr)) {
|
||||
ALOGE("Cannot bring up %s: %s", interface, strerror(errno));
|
||||
fclose(state);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -102,6 +103,7 @@ int main(int argc, char **argv)
|
|||
if (!set_address(&ifr.ifr_addr, address) ||
|
||||
ioctl(s, SIOCSIFADDR, &ifr)) {
|
||||
ALOGE("Cannot set address: %s", strerror(errno));
|
||||
fclose(state);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -109,6 +111,7 @@ int main(int argc, char **argv)
|
|||
if (set_address(&ifr.ifr_netmask, env("INTERNAL_NETMASK4"))) {
|
||||
if (ioctl(s, SIOCSIFNETMASK, &ifr)) {
|
||||
ALOGE("Cannot set netmask: %s", strerror(errno));
|
||||
fclose(state);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -123,6 +126,7 @@ int main(int argc, char **argv)
|
|||
fprintf(state, "%s\n", env("REMOTE_ADDR"));
|
||||
} else {
|
||||
ALOGE("Cannot parse parameters");
|
||||
fclose(state);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue