diff options
author | 2012-02-29 08:44:14 +0000 | |
---|---|---|
committer | 2012-02-29 08:44:14 +0000 | |
commit | dec2d449e59a88e8558fe681f64f8a92e3bb3016 (patch) | |
tree | b79a14850f286fee961c31d019e3c9439eb1262b /lib/libc/stdlib | |
parent | Add support for Roland UM-ONE, from Tom Ivar Helbekkmo in NetBSD PR 45908. (diff) | |
download | wireguard-openbsd-dec2d449e59a88e8558fe681f64f8a92e3bb3016.tar.xz wireguard-openbsd-dec2d449e59a88e8558fe681f64f8a92e3bb3016.zip |
- Test for the retrieved page address not being NULL. This turns free((void*)1)
into an bogus pointer error instead of a segfault.
- Document that we use the assumption that a non-MAP_FIXED mmap() with
hint 0 never returns NULL.
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r-- | lib/libc/stdlib/malloc.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 5fc75c2c75a..6aba00e4a0b 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.140 2011/10/06 14:37:04 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.141 2012/02/29 08:44:14 otto Exp $ */ /* * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net> * @@ -724,6 +724,11 @@ alloc_chunk_info(struct dir_info *d, int bits) return p; } + +/* + * The hashtable uses the assumption that p is never NULL. This holds since + * non-MAP_FIXED mappings with hint 0 start at BRKSIZ. + */ static int insert(struct dir_info *d, void *p, size_t sz, void *f) { @@ -774,7 +779,7 @@ find(struct dir_info *d, void *p) q = MASK_POINTER(r); STATS_INC(d->find_collisions); } - return q == p ? &d->r[index] : NULL; + return (q == p && r != NULL) ? &d->r[index] : NULL; } static void |