Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e740353f authored by Greg Kaiser's avatar Greg Kaiser
Browse files

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
parent 3e167da9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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;
    }