diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs
index ee39ae059a286077ec391740ab89f3f3b2412b5c..59d6de502bccd3fe831aa0d1af1ba5b2e224ab39 100644
--- a/src/header/stdlib/mod.rs
+++ b/src/header/stdlib/mod.rs
@@ -812,6 +812,22 @@ pub unsafe extern "C" fn realloc(ptr: *mut c_void, size: size_t) -> *mut c_void
     new_ptr
 }
 
+#[no_mangle]
+pub unsafe extern "C" fn reallocarray(ptr: *mut c_void, m: size_t, n: size_t) -> *mut c_void {
+    //Handle possible integer overflow in size calculation
+    match m.checked_mul(n) {
+        Some(size) => {
+            realloc(ptr, size)
+        }
+        None => {
+            // For overflowing multiplication, we have to set errno here
+            platform::errno = ENOMEM;
+            ptr::null_mut()
+
+        }
+    }
+}
+
 #[no_mangle]
 pub unsafe extern "C" fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char {
     let ptr = if resolved.is_null() {
diff --git a/tests/expected/bins_static/stdlib/alloc.stdout b/tests/expected/bins_static/stdlib/alloc.stdout
index e59a48d031c4eddde8ed3efa4577880b5af4e449..02ecd2018979000a2b812e1ff4f7cc625e566a86 100644
--- a/tests/expected/bins_static/stdlib/alloc.stdout
+++ b/tests/expected/bins_static/stdlib/alloc.stdout
@@ -7,6 +7,8 @@ calloc (overflowing): pointer: (nil), error value: 12 = Out of memory
 realloc (size 0): (OK)
 realloc: pointer: (not NULL), error value: 0 = Success
 realloc (SIZE_MAX): pointer: (nil), error value: 12 = Out of memory
+reallocarray: pointer: (not NULL), error value: 0 = Success
+reallocarray (SIZE_MAX): pointer: (nil), error value: 12 = Out of memory
 memalign (size 0): (OK)
 memalign: pointer: (alignment OK), error value: 0 = Success
 memalign (SIZE_MAX): pointer: (nil), error value: 12 = Out of memory
diff --git a/tests/stdlib/alloc.c b/tests/stdlib/alloc.c
index 366603637579d262d7792b8106d0a52c50f15acd..f15149b5b0c96cf18db2d6a9d680775f8bed0207 100644
--- a/tests/stdlib/alloc.c
+++ b/tests/stdlib/alloc.c
@@ -165,6 +165,22 @@ int main(void) {
     printf("realloc (SIZE_MAX): ");
     test_cannot_alloc(ptr_realloc_maxsize, realloc_maxsize_errno);
     free(ptr_realloc_maxsize);
+
+    errno = 0;
+    char * ptr_reallocarray_maxsize = (char *)malloc(sample_alloc_size);
+    ptr_reallocarray_maxsize = (char *)reallocarray(ptr_reallocarray_maxsize, 2, sample_alloc_size);
+    int reallocarray_errno = errno;
+    printf("reallocarray: ");
+    test_non_null(ptr_reallocarray_maxsize, reallocarray_errno);
+    for(i = 0; i < sample_realloc_size; i++) {
+        ptr_realloc[i] = (char)i;
+    }
+    errno = 0;
+    ptr_reallocarray_maxsize = (char *)reallocarray(ptr_reallocarray_maxsize, 2, max_size);
+    reallocarray_errno = errno;
+    printf("reallocarray (SIZE_MAX): ");
+    test_cannot_alloc(ptr_reallocarray_maxsize, reallocarray_errno);
+    free(ptr_reallocarray_maxsize);
     
     errno = 0;
     char * ptr_memalign_size0 = (char *)memalign(aligned_alloc_alignment, zero_size);