fix memory leaks in error paths
authorjsg <jsg@openbsd.org>
Mon, 19 Oct 2015 14:15:59 +0000 (14:15 +0000)
committerjsg <jsg@openbsd.org>
Mon, 19 Oct 2015 14:15:59 +0000 (14:15 +0000)
ok renato@

usr.sbin/eigrpd/parse.y

index f8b1ac8..99b6903 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: parse.y,v 1.2 2015/10/04 22:54:38 renato Exp $ */
+/*     $OpenBSD: parse.y,v 1.3 2015/10/19 14:15:59 jsg Exp $ */
 
 /*
  * Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -1161,14 +1161,19 @@ host(const char *s, union eigrpd_addr *addr, uint8_t *plen)
        memset(addr, 0, sizeof(union eigrpd_addr));
        switch (af) {
        case AF_INET:
-               if (inet_pton(AF_INET, ps, &addr->v4) != 1)
+               if (inet_pton(AF_INET, ps, &addr->v4) != 1) {
+                       free(ps);
                        return (-1);
+               }
                break;
        case AF_INET6:
-               if (inet_pton(AF_INET6, ps, &addr->v6) != 1)
+               if (inet_pton(AF_INET6, ps, &addr->v6) != 1) {
+                       free(ps);
                        return (-1);
+               }
                break;
        default:
+               free(ps);
                return (-1);
        }
        eigrp_applymask(af, addr, addr, *plen);