resolv: Fix memory leak with OOM during resolv.conf parsing [BZ #22095]
authorFlorian Weimer <fweimer@redhat.com>
Wed, 6 Sep 2017 13:20:25 +0000 (15:20 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 6 Sep 2017 13:20:25 +0000 (15:20 +0200)
ChangeLog
resolv/res_init.c

index d54e13d05c088439519f6a00079b3a6f37fe4922..298f0fdcbdbc88ca4af7dee534228ffefbd5cb42 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-06  Florian Weimer  <fweimer@redhat.com>
+
+       [BZ #22095]
+       * resolv/res_init.c (res_vinit_1): Avoid memory leak in case of
+       dynarray allocation failure.
+
 2017-09-06  Florian Weimer  <fweimer@redhat.com>
 
        Remove dead PTR IPv4-to-IPv6 mapping code from nss_dns.
index fa46ce7813c1f8af1418c5a99cfe4e414d575142..4e1f9fe8dea93e8add506d9152b0e943986eb67e 100644 (file)
@@ -446,6 +446,11 @@ res_vinit_1 (FILE *fp, struct resolv_conf_parser *parser)
                     (&parser->nameserver_list);
                   if (p != NULL)
                     *p = sa;
+                  else
+                    {
+                      free (sa);
+                      return false;
+                    }
                 }
               continue;
             }