From: Frank Meerkötter Date: Mon, 3 Dec 2012 18:29:16 +0000 (+0100) Subject: fix error checking of asprintf X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=commitdiff_plain;h=a02432a5ecbb588964a1800122a213822da96f3c 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 --- 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;