summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-08-27 16:31:29 +0900
committerSung-jae Park <nicesj.park@samsung.com>2013-08-28 10:44:52 +0900
commit978f477fcfabfa587238ee920254fb65aab41b14 (patch)
tree22b913b93fd1efbf65c66b8578253f72e98ef67b
parent63e7612ece0337c8e78364392988b41f90fbb65f (diff)
downloadheap-monitor-978f477fcfabfa587238ee920254fb65aab41b14.tar.gz
heap-monitor-978f477fcfabfa587238ee920254fb65aab41b14.tar.bz2
heap-monitor-978f477fcfabfa587238ee920254fb65aab41b14.zip
Fix prevent issues
Change-Id: Ice92c21bf7e3181199b9a481c69fd396ed4a6872
-rw-r--r--packaging/libheap-monitor.spec2
-rw-r--r--src/allocator.c4
-rw-r--r--src/heap-monitor.c10
3 files changed, 14 insertions, 2 deletions
diff --git a/packaging/libheap-monitor.spec b/packaging/libheap-monitor.spec
index 8c1e010..62f162f 100644
--- a/packaging/libheap-monitor.spec
+++ b/packaging/libheap-monitor.spec
@@ -1,6 +1,6 @@
Name: libheap-monitor
Summary: Library for monitoring the heap usage
-Version: 0.0.16
+Version: 0.0.17
Release: 1
Group: HomeTF/Livebox
License: Flora License
diff --git a/src/allocator.c b/src/allocator.c
index 347aa0c..829f519 100644
--- a/src/allocator.c
+++ b/src/allocator.c
@@ -150,6 +150,10 @@ void *allocator_alloc(struct allocator *handle, int size)
break;
}
} while ((tmp = tmp->next) && tmp != handle->used);
+
+ if (!tmp) {
+ tmp = handle->used;
+ }
}
tmp->prev->next = chunk;
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)