summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libc/stdlib/malloc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index b858bbb739..028eff2b2d 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc.c,v 1.82 2006/04/24 19:23:42 otto Exp $ */ 1/* $OpenBSD: malloc.c,v 1.83 2006/05/14 19:53:40 otto Exp $ */
2 2
3/* 3/*
4 * ---------------------------------------------------------------------------- 4 * ----------------------------------------------------------------------------
@@ -1158,6 +1158,10 @@ imalloc(size_t size)
1158 if (suicide) 1158 if (suicide)
1159 abort(); 1159 abort();
1160 1160
1161 /* does not matter if malloc_bytes fails */
1162 if (px == NULL)
1163 px = malloc_bytes(sizeof *px);
1164
1161 if (malloc_ptrguard && size == PTR_SIZE) { 1165 if (malloc_ptrguard && size == PTR_SIZE) {
1162 ptralloc = 1; 1166 ptralloc = 1;
1163 size = malloc_pagesize; 1167 size = malloc_pagesize;
@@ -1405,8 +1409,8 @@ free_pages(void *ptr, u_long index, struct pginfo * info)
1405 mprotect(ptr, l, PROT_NONE); 1409 mprotect(ptr, l, PROT_NONE);
1406 1410
1407 /* Add to free-list. */ 1411 /* Add to free-list. */
1408 if (px == NULL) 1412 if (px == NULL && (px = malloc_bytes(sizeof *px)) == NULL)
1409 px = imalloc(sizeof *px); /* This cannot fail... */ 1413 goto not_return;
1410 px->page = ptr; 1414 px->page = ptr;
1411 px->pdir = spi; 1415 px->pdir = spi;
1412 px->size = l; 1416 px->size = l;
@@ -1766,6 +1770,11 @@ ifree(void *ptr)
1766 free_pages(ptr, index, info); 1770 free_pages(ptr, index, info);
1767 else 1771 else
1768 free_bytes(ptr, index, info); 1772 free_bytes(ptr, index, info);
1773
1774 /* does not matter if malloc_bytes fails */
1775 if (px == NULL)
1776 px = malloc_bytes(sizeof *px);
1777
1769 return; 1778 return;
1770} 1779}
1771 1780