artulab
projects
/
openbsd
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9b4396f
)
Just return if nmemb is 0. Avoids a NULL dereference and is
author
millert
<millert@openbsd.org>
Sun, 21 Jun 2015 03:20:56 +0000
(
03:20
+0000)
committer
millert
<millert@openbsd.org>
Sun, 21 Jun 2015 03:20:56 +0000
(
03:20
+0000)
consistent with the behavior of the other libc sort functions.
OK deraadt@
lib/libc/stdlib/merge.c
patch
|
blob
|
history
diff --git
a/lib/libc/stdlib/merge.c
b/lib/libc/stdlib/merge.c
index
43ef8b0
..
d60317c
100644
(file)
--- a/
lib/libc/stdlib/merge.c
+++ b/
lib/libc/stdlib/merge.c
@@
-1,4
+1,4
@@
-/* $OpenBSD: merge.c,v 1.
9 2011/03/06 00:55:38 deraad
t Exp $ */
+/* $OpenBSD: merge.c,v 1.
10 2015/06/21 03:20:56 miller
t Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@
-101,6
+101,9
@@
mergesort(void *base, size_t nmemb, size_t size,
return (-1);
}
+ if (nmemb == 0)
+ return (0);
+
/*
* XXX
* Stupid subtraction for the Cray.