[OpenWrt-Devel] [PATCH] Deal with allocation errors in a few missing places.

Felix Fietkau nbd at openwrt.org
Mon Jul 6 17:13:42 EDT 2015


On 2015-06-26 00:20, Juliusz Chroboczek wrote:
> Since libubox is used by procd, it should deal gracefully with allocation
> failures.
> ---
>  blobmsg_json.c |  2 ++
>  json_script.c  |  3 +++
>  kvlist.c       |  4 ++++
>  ustream.c      | 16 +++++++++++++---
>  utils.c        |  3 +++
>  5 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/blobmsg_json.c b/blobmsg_json.c
> index ffde23d..1f2b4bc 100644
> --- a/blobmsg_json.c
> +++ b/blobmsg_json.c
> @@ -297,6 +297,8 @@ char *blobmsg_format_json_with_cb(struct blob_attr *attr, bool list, blobmsg_jso
>  
>  	s.len = blob_len(attr);
>  	s.buf = malloc(s.len);
> +        if (!s.buf)
> +            return NULL;
Please use tab instead of spaces for indenting.

- Felix
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list