about summary refs log tree commit diff
path: root/utils
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2022-10-01 16:10:09 +0100
committerDavid Carlier <devnexen@gmail.com>2022-10-01 16:12:32 +0100
commit0eeddda2c84b13158bfda1505e5ff2467dec08f0 (patch)
tree9e3d2ca930b62e9c243727b1b0c92a96e3d88501 /utils
parent586aec711679e1cdaac17cc9749746055fdb55f8 (diff)
downloadafl++-0eeddda2c84b13158bfda1505e5ff2467dec08f0.tar.gz
libdislocator adding netbsd's reallocarr
Diffstat (limited to 'utils')
-rw-r--r--utils/libdislocator/libdislocator.so.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/utils/libdislocator/libdislocator.so.c b/utils/libdislocator/libdislocator.so.c
index a6d8ecfd..638735ef 100644
--- a/utils/libdislocator/libdislocator.so.c
+++ b/utils/libdislocator/libdislocator.so.c
@@ -510,6 +510,24 @@ __attribute__((alloc_size(2, 3))) void *reallocarray(void *ptr, size_t elem_len,
 
 }
 
+int reallocarr(void *ptr, size_t elem_len, size_t elem_cnt) {
+
+  void *ret = NULL;
+  const size_t elem_tot = elem_len * elem_cnt;
+
+  if (elem_tot == 0) {
+
+    void **h = &ptr;
+    *h = ret;
+    return 0;
+
+  }
+
+  ret = reallocarray(ptr, elem_len, elem_cnt);
+  return ret ? 0 : -1;
+
+}
+
 #if defined(__APPLE__)
 size_t malloc_size(const void *ptr) {