Module Name: src
Committed By: martin
Date: Thu Aug 31 15:05:50 UTC 2017
Modified Files:
src/lib/libc/stdlib [netbsd-6]: 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).
XXX: pullup-8
XXX: pullup-7
XXX: pullup-6
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.6.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.13 src/lib/libc/stdlib/merge.c:1.13.6.1
--- src/lib/libc/stdlib/merge.c:1.13 Wed May 18 19:36:36 2011
+++ src/lib/libc/stdlib/merge.c Thu Aug 31 15:05:50 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: merge.c,v 1.13 2011/05/18 19:36:36 dsl Exp $ */
+/* $NetBSD: merge.c,v 1.13.6.1 2017/08/31 15:05:50 martin 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.13 2011/05/18 19:36:36 dsl Exp $");
+__RCSID("$NetBSD: merge.c,v 1.13.6.1 2017/08/31 15:05:50 martin Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -128,6 +128,9 @@ mergesort(base, nmemb, size, cmp)
return (-1);
}
+ if (nmemb == 0)
+ return (0);
+
/*
* XXX
* Stupid subtraction for the Cray.