gluon-radv-filterd: Handle malloc errors
The allocation of a new router object can fail. It must therefore be handled to avoid segfaults. Signed-off-by: Sven Eckelmann <sven@narfation.org>
This commit is contained in:
parent
7014d9eb14
commit
2d6cd71f82
@ -290,6 +290,9 @@ static struct router *router_add(const struct ether_addr *mac) {
|
|||||||
struct router *router;
|
struct router *router;
|
||||||
|
|
||||||
router = malloc(sizeof(*router));
|
router = malloc(sizeof(*router));
|
||||||
|
if (!router)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
router->src = *mac;
|
router->src = *mac;
|
||||||
router->next = G.routers;
|
router->next = G.routers;
|
||||||
G.routers = router;
|
G.routers = router;
|
||||||
@ -304,6 +307,8 @@ static void router_update(const struct ether_addr *mac, uint16_t timeout) {
|
|||||||
router = router_find_src(mac);
|
router = router_find_src(mac);
|
||||||
if (!router)
|
if (!router)
|
||||||
router = router_add(mac);
|
router = router_add(mac);
|
||||||
|
if (!router)
|
||||||
|
return;
|
||||||
|
|
||||||
router->eol = time(NULL) + timeout;
|
router->eol = time(NULL) + timeout;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user