summaryrefslogtreecommitdiffstats
path: root/rtemsbsd/rtems/rtems-routes.c
diff options
context:
space:
mode:
authorKinsey Moore <kinsey.moore@oarcorp.com>2024-01-23 13:45:39 -0600
committerJoel Sherrill <joel@rtems.org>2024-01-31 14:01:49 -0600
commit63deac0401519271445d0153476553e54fb44ce5 (patch)
tree302ae35bc0f478bf0135ca407fe7fcf6b5954ecd /rtemsbsd/rtems/rtems-routes.c
parentrtemsbsd/rtems: Check function return values (diff)
downloadrtems-libbsd-63deac0401519271445d0153476553e54fb44ce5.tar.bz2
rtemsbsd/rtems: Don't leak memory on error
Diffstat (limited to '')
-rw-r--r--rtemsbsd/rtems/rtems-routes.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/rtemsbsd/rtems/rtems-routes.c b/rtemsbsd/rtems/rtems-routes.c
index 6663e8d4..0b5250f0 100644
--- a/rtemsbsd/rtems/rtems-routes.c
+++ b/rtemsbsd/rtems/rtems-routes.c
@@ -85,8 +85,10 @@ int rtems_get_route(const struct sockaddr_in* sin, struct sockaddr** rti_info)
}
s = socket(AF_ROUTE, SOCK_RAW, AF_UNSPEC);
- if (s < 0)
+ if (s < 0) {
+ free(buf);
return -1;
+ }
rtm = (struct rt_msghdr *) buf;
rtm->rtm_msglen = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in);