summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-06-10 15:54:45 +0200
committerThomas Haller <thaller@redhat.com>2014-06-10 21:45:52 +0200
commit87682a093a64788a848c13ca77c8e626dd4b2b03 (patch)
treec4e31d3a162a81df9e76ab9da30851735424705a /src
parentd50758cbfe7741650bc470f349ead29f824dd182 (diff)
downloadlibnl-87682a093a64788a848c13ca77c8e626dd4b2b03.tar.gz
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 <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/nl-route-get.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nl-route-get.c b/src/nl-route-get.c
index c2f07d4c..9d9a4484 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);