Module Name: src Committed By: ginsbach Date: Sat Aug 12 01:10:04 UTC 2017
Modified Files: src/lib/libc/stdlib: merge.c Log Message: 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.14 -r1.15 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.15 --- src/lib/libc/stdlib/merge.c:1.14 Tue Mar 13 21:13:48 2012 +++ src/lib/libc/stdlib/merge.c Sat Aug 12 01:10:04 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: merge.c,v 1.14 2012/03/13 21:13:48 christos Exp $ */ +/* $NetBSD: merge.c,v 1.15 2017/08/12 01:10:04 ginsbach 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.15 2017/08/12 01:10:04 ginsbach 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.