From a02432a5ecbb588964a1800122a213822da96f3c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Frank=20Meerk=C3=B6tter?= Date: Mon, 3 Dec 2012 19:29:16 +0100 Subject: [PATCH] fix error checking of asprintf MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- ubus.c | 3 +-- 1 file changed, 1 insertion(+), 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; -- 2.25.1