[systemd-devel] [PATCH] journal-remote-parse: avoid passing null to memchr
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Sat Apr 5 13:08:29 PDT 2014
On Sat, Apr 05, 2014 at 09:09:47PM +0200, Thomas H.P. Andersen wrote:
> static int get_line(RemoteSource *source, char **line, size_t *size) {
> ssize_t n, remain;
> - char *c;
> + char *c = NULL;
> char *newbuf = NULL;
> size_t newsize = 0;
>
> @@ -49,7 +49,9 @@ static int get_line(RemoteSource *source, char **line, size_t *size) {
> assert(source->filled <= source->size);
> assert(source->buf == NULL || source->size > 0);
>
> - c = memchr(source->buf, '\n', source->filled);
> + if (source->buf)
> + c = memchr(source->buf, '\n', source->filled);
> +
> if (c != NULL)
Looks good. Please push.
Zbyszek
More information about the systemd-devel
mailing list