summaryrefslogtreecommitdiffhomepage
path: root/ubus.c
diff options
context:
space:
mode:
authorFrank Meerkötter <frank@meerkoetter.org>2012-12-03 19:29:16 +0100
committerFelix Fietkau <nbd@openwrt.org>2012-12-03 19:46:37 +0100
commita02432a5ecbb588964a1800122a213822da96f3c (patch)
treeef328c7fca26c47a611c964393488aaea6d32c2f /ubus.c
parentc9242aed7daac67b338f6792b06afe78ffc57011 (diff)
fix error checking of asprintf
see man asprintf [...] RETURN VALUE When successful, these functions return the number of bytes printed, just like sprintf(3). If memory allocation wasn't possible, or some other error occurs, these functions will return -1, and the contents of strp is undefined. Signed-off-by: Frank Meerkötter <frank@meerkoetter.org>
Diffstat (limited to 'ubus.c')
-rw-r--r--ubus.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/ubus.c b/ubus.c
index 7b85930..d6d4188 100644
--- a/ubus.c
+++ b/ubus.c
@@ -727,8 +727,7 @@ netifd_ubus_add_interface(struct interface *iface)
struct ubus_object *obj = &iface->ubus;
char *name = NULL;
- asprintf(&name, "%s.interface.%s", main_object.name, iface->name);
- if (!name)
+ if (asprintf(&name, "%s.interface.%s", main_object.name, iface->name) == -1)
return;
obj->name = name;