Browse Source

Just return if nmemb is 0. Avoids a NULL dereference and is

consistent with the behavior of the other libc sort functions.
OK deraadt@
OPENBSD_5_8
millert 9 years ago
parent
commit
7b99cfa53d
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      src/lib/libc/stdlib/merge.c

+ 4
- 1
src/lib/libc/stdlib/merge.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: merge.c,v 1.9 2011/03/06 00:55:38 deraadt Exp $ */
/* $OpenBSD: merge.c,v 1.10 2015/06/21 03:20:56 millert Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved. * 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); return (-1);
} }
if (nmemb == 0)
return (0);
/* /*
* XXX * XXX
* Stupid subtraction for the Cray. * Stupid subtraction for the Cray.


Loading…
Cancel
Save