diff options
author | millert <> | 2015-06-21 03:20:56 +0000 |
---|---|---|
committer | millert <> | 2015-06-21 03:20:56 +0000 |
commit | 5712bedec3ebd1a6f14885e7c138af02fab74449 (patch) | |
tree | 77e8d69e530876e86f0aab4eb2d5d11941eca71c | |
parent | 432767f47a21becad33b3d167c69e632685ceefb (diff) | |
download | openbsd-5712bedec3ebd1a6f14885e7c138af02fab74449.tar.gz openbsd-5712bedec3ebd1a6f14885e7c138af02fab74449.tar.bz2 openbsd-5712bedec3ebd1a6f14885e7c138af02fab74449.zip |
Just return if nmemb is 0. Avoids a NULL dereference and is
consistent with the behavior of the other libc sort functions.
OK deraadt@
-rw-r--r-- | src/lib/libc/stdlib/merge.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/libc/stdlib/merge.c b/src/lib/libc/stdlib/merge.c index 43ef8b08e2..d60317ce08 100644 --- a/src/lib/libc/stdlib/merge.c +++ b/src/lib/libc/stdlib/merge.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: merge.c,v 1.9 2011/03/06 00:55:38 deraadt Exp $ */ | 1 | /* $OpenBSD: merge.c,v 1.10 2015/06/21 03:20:56 millert Exp $ */ |
2 | /*- | 2 | /*- |
3 | * Copyright (c) 1992, 1993 | 3 | * Copyright (c) 1992, 1993 |
4 | * The Regents of the University of California. All rights reserved. | 4 | * The Regents of the University of California. All rights reserved. |
@@ -101,6 +101,9 @@ mergesort(void *base, size_t nmemb, size_t size, | |||
101 | return (-1); | 101 | return (-1); |
102 | } | 102 | } |
103 | 103 | ||
104 | if (nmemb == 0) | ||
105 | return (0); | ||
106 | |||
104 | /* | 107 | /* |
105 | * XXX | 108 | * XXX |
106 | * Stupid subtraction for the Cray. | 109 | * Stupid subtraction for the Cray. |