From 87682a093a64788a848c13ca77c8e626dd4b2b03 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 10 Jun 2014 15:54:45 +0200 Subject: [PATCH] cli: add error checking to nl-route-get about out-of-memory This is mainly to appease coverity which warned about this. Acked-by: Thomas Graf Signed-off-by: Thomas Haller --- src/nl-route-get.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/nl-route-get.c b/src/nl-route-get.c index c2f07d4..9d9a448 100644 --- a/src/nl-route-get.c +++ b/src/nl-route-get.c @@ -65,8 +65,12 @@ int main(int argc, char *argv[]) }; m = nlmsg_alloc_simple(RTM_GETROUTE, 0); - nlmsg_append(m, &rmsg, sizeof(rmsg), NLMSG_ALIGNTO); - nla_put_addr(m, RTA_DST, dst); + if (!m) + nl_cli_fatal(ENOMEM, "out of memory"); + if (nlmsg_append(m, &rmsg, sizeof(rmsg), NLMSG_ALIGNTO) < 0) + nl_cli_fatal(ENOMEM, "out of memory"); + if (nla_put_addr(m, RTA_DST, dst) < 0) + nl_cli_fatal(ENOMEM, "out of memory"); err = nl_send_auto_complete(sock, m); nlmsg_free(m);