From: Quentin Young Date: Mon, 16 Apr 2018 19:36:12 +0000 (-0400) Subject: ospf6d: handle realloc() failure in lsa test X-Git-Tag: frr-5.0-dev~43^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=0e9f8d2d8637b86889fc82ecca60d1b23bdfccfd;p=matthieu%2Ffrr.git ospf6d: handle realloc() failure in lsa test Signed-off-by: Quentin Young --- diff --git a/tests/ospf6d/test_lsdb.c b/tests/ospf6d/test_lsdb.c index 633e88e769..ec0835c719 100644 --- a/tests/ospf6d/test_lsdb.c +++ b/tests/ospf6d/test_lsdb.c @@ -38,9 +38,15 @@ static size_t lsa_count = 0; static void lsa_check_resize(size_t len) { + struct ospf6_lsa **templsas; + if (lsa_count >= len) return; - lsas = realloc(lsas, len * sizeof(lsas[0])); + templsas = realloc(lsas, len * sizeof(lsas[0])); + if (templsas) + lsas = templsas; + else + return; memset(lsas + lsa_count, 0, sizeof(lsas[0]) * (len - lsa_count)); lsa_count = len;