[COMMITTED] resolv: Fix memory leak with OOM during resolv.conf parsing [BZ #22095]

Message ID 20170906132307.814774194EE18@oldenburg.str.redhat.com
State New
Headers show
Series
  • [COMMITTED] resolv: Fix memory leak with OOM during resolv.conf parsing [BZ #22095]
Related show

Commit Message

Florian Weimer Sept. 6, 2017, 1:23 p.m.
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.

Patch

diff --git a/resolv/res_init.c b/resolv/res_init.c
index fa46ce7813..4e1f9fe8de 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -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;
             }