Module Name:    src
Committed By:   pooka
Date:           Sun Jan  9 14:15:07 UTC 2011

Modified Files:
        src/lib/librumphijack: hijack.c

Log Message:
Don't depend on malloc(0) returning non-NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.5 src/lib/librumphijack/hijack.c:1.6
--- src/lib/librumphijack/hijack.c:1.5	Sun Jan  9 10:28:46 2011
+++ src/lib/librumphijack/hijack.c	Sun Jan  9 14:15:06 2011
@@ -1,4 +1,4 @@
-/*      $NetBSD: hijack.c,v 1.5 2011/01/09 10:28:46 pooka Exp $	*/
+/*      $NetBSD: hijack.c,v 1.6 2011/01/09 14:15:06 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: hijack.c,v 1.5 2011/01/09 10:28:46 pooka Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.6 2011/01/09 14:15:06 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -627,9 +627,13 @@
 		}
 	}
 
-	pfds = malloc(sizeof(*pfds) * realnfds);
-	if (!pfds)
-		return -1;
+	if (realnfds) {
+		pfds = malloc(sizeof(*pfds) * realnfds);
+		if (!pfds)
+			return -1;
+	} else {
+		pfds = NULL;
+	}
 
 	for (i = 0, j = 0; i < nfds; i++) {
 		incr = 0;

Reply via email to