summaryrefslogtreecommitdiffstats
authornicm <nicm>2010-11-11 20:41:08 (GMT)
committer Raghavendra D Prabhu <[email protected]>2011-01-02 18:59:31 (GMT)
commitc83ca39dfd8bf4b544be471e4e46136484296ebc (patch) (side-by-side diff)
treea70e931b6a9c6acc4f0042354f43b0ba6f2a6d7f
parent16e22390d455323612bf272d3028546e9cac4796 (diff)
downloadtmux-old-c83ca39dfd8bf4b544be471e4e46136484296ebc.zip
tmux-old-c83ca39dfd8bf4b544be471e4e46136484296ebc.tar.gz
tmux-old-c83ca39dfd8bf4b544be471e4e46136484296ebc.tar.bz2
malloc(0) may return NULL, so only assume that is an error if allocating
more than zero.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--compat/imsg.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/compat/imsg.c b/compat/imsg.c
index 987d8fd..95a2419 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)