diff options
Diffstat (limited to 'src/heap-monitor.c')
-rw-r--r-- | src/heap-monitor.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/heap-monitor.c b/src/heap-monitor.c index 5e91cec..7908c08 100644 --- a/src/heap-monitor.c +++ b/src/heap-monitor.c @@ -404,6 +404,7 @@ API void *realloc(void *__ptr, size_t size) if (!size) { free(__ptr); + return NULL; } else if (!__ptr) { return malloc(size); } @@ -559,7 +560,14 @@ API int posix_memalign(void **memptr, size_t alignment, size_t size) API void *vmalloc(size_t size) { - return memalign(sysconf(_SC_PAGESIZE), size); + int pagesz; + + pagesz = sysconf(_SC_PAGESIZE); + if (pagesz < 0) { + ErrPrint("%s\n", strerror(errno)); + pagesz = 4096; + } + return memalign(pagesz, size); } static int iterator_cb(struct dl_phdr_info *info, size_t size, void *data) |