diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2010-11-11 20:41:08 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2010-11-11 20:41:08 +0000 |
commit | 94c2adf49958c568b940bb1394fa5f62c492cb2d (patch) | |
tree | c5addba5c9c8a7da875923f989ead9e484a5c1e2 | |
parent | 9c541e42f0adc941cbab49844f0f01b320d6a05f (diff) | |
download | rtmux-94c2adf49958c568b940bb1394fa5f62c492cb2d.tar.gz rtmux-94c2adf49958c568b940bb1394fa5f62c492cb2d.tar.bz2 rtmux-94c2adf49958c568b940bb1394fa5f62c492cb2d.zip |
malloc(0) may return NULL, so only assume that is an error if allocating
more than zero.
-rw-r--r-- | compat/imsg.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compat/imsg.c b/compat/imsg.c index bea7bb3f..6f56465d 100644 --- a/compat/imsg.c +++ b/compat/imsg.c @@ -1,4 +1,4 @@ -/* $Id: imsg.c,v 1.5 2010-06-06 00:08:28 tcunha Exp $ */ +/* $Id: imsg.c,v 1.6 2010-11-11 20:41:08 nicm Exp $ */ /* $OpenBSD: imsg.c,v 1.3 2010/05/26 13:56:07 nicm Exp $ */ /* @@ -111,7 +111,7 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg) return (0); datalen = imsg->hdr.len - IMSG_HEADER_SIZE; ibuf->r.rptr = ibuf->r.buf + IMSG_HEADER_SIZE; - if ((imsg->data = malloc(datalen)) == NULL) + if (datalen != 0 && (imsg->data = malloc(datalen + 1)) == NULL) return (-1); if (imsg->hdr.flags & IMSGF_HASFD) |