Module Name:    src
Committed By:   snj
Date:           Mon Sep  4 06:21:45 UTC 2017

Modified Files:
        src/lib/libc/stdlib [netbsd-7]: merge.c

Log Message:
Pull up following revision(s) (requested by ginsbach in ticket #1495):
        lib/libc/stdlib/merge.c: revision 1.15
PR lib/50316: Gracefully handle a zero number of members argument.
Taken from FreeBSD (which fixed this same issue long ago).


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.10.1 src/lib/libc/stdlib/merge.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/libc/stdlib/merge.c
diff -u src/lib/libc/stdlib/merge.c:1.14 src/lib/libc/stdlib/merge.c:1.14.10.1
--- src/lib/libc/stdlib/merge.c:1.14	Tue Mar 13 21:13:48 2012
+++ src/lib/libc/stdlib/merge.c	Mon Sep  4 06:21:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: merge.c,v 1.14 2012/03/13 21:13:48 christos Exp $	*/
+/*	$NetBSD: merge.c,v 1.14.10.1 2017/09/04 06:21:45 snj Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "from: @(#)merge.c	8.2 (Berkeley) 2/14/94";
 #else
-__RCSID("$NetBSD: merge.c,v 1.14 2012/03/13 21:13:48 christos Exp $");
+__RCSID("$NetBSD: merge.c,v 1.14.10.1 2017/09/04 06:21:45 snj Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -125,6 +125,9 @@ mergesort(void *base, size_t nmemb, size
 		return (-1);
 	}
 
+	if (nmemb == 0)
+		return (0);
+
 	/*
 	 * XXX
 	 * Stupid subtraction for the Cray.

Reply via email to