On 6 January 2016 at 19:56, Frank Henigman <[email protected]> wrote:
> +static void
> +put(struct json *jj, char *s)
> +{
> + if (!jj->buf)
> + return;
> +
> + for (;;) {
> + if (!(*jj->pos = *s++))
> + break;
> + if (++jj->pos == jj->buf + jj->size) {
> + size_t z = jj->size * 2;
> + jj->buf = realloc(jj->buf, z);
> + if (!jj->buf)
As I did not look closely at the patch this piece made me believe it
will corrupt the output. Although it will only leak memory.
Namely: if realloc fails, the old pointer is lost yet the data isn't freed.
> + char *buf = malloc(strlen(s) * 3 + 2);
> + if (!buf)
Nit: Just return NULL and drop the label ? Imho there is no point in
jumping only to free(NULL).
Thanks
Emil
_______________________________________________
waffle mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/waffle