[LEDE-DEV] [PATCH] libubux: add 2 missing free calls and change a char to const char.

Yousong Zhou yszhou4tech at gmail.com
Tue Oct 31 00:11:52 PDT 2017


On 31 October 2017 at 09:49, Rosen Penev <rosenp at gmail.com> wrote:
> Reduces compiled size by 48 bytes.
>
> Signed-off-by: Rosen Penev <rosenp at gmail.com>
> ---
>  jshn.c    | 4 +++-
>  ustream.c | 1 +
>  2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/jshn.c b/jshn.c
> index 4989099..d47e98d 100644
> --- a/jshn.c
> +++ b/jshn.c
> @@ -103,7 +103,7 @@ static void write_key_string(const char *key)
>
>  static int add_json_element(const char *key, json_object *obj)
>  {
> -       char *type;
> +       const char *type;
>
>         if (!obj)
>                 return -1;
> @@ -354,6 +354,8 @@ int main(int argc, char **argv)
>                 avl_insert(&env_vars, &vars[i].avl);
>         }
>
> +       free(vars);
> +
>         while ((ch = getopt(argc, argv, "p:nir:w")) != -1) {
>                 switch(ch) {
>                 case 'p':
> diff --git a/ustream.c b/ustream.c
> index d36ce08..1cb0faf 100644
> --- a/ustream.c
> +++ b/ustream.c
> @@ -70,6 +70,7 @@ static int ustream_alloc_default(struct ustream *s, struct ustream_buf_list *l)
>
>         ustream_init_buf(buf, l->buffer_len);
>         ustream_add_buf(l, buf);
> +       free(buf);
>

NACK because freeing these two allocated memories immediately will
cause use-after-free issues.

                yousong



More information about the Lede-dev mailing list