diff --git a/tests/stdlib/alloc.c b/tests/stdlib/alloc.c
index c55aef5e49872d487a4f74d389941a2808d0f582..366603637579d262d7792b8106d0a52c50f15acd 100644
--- a/tests/stdlib/alloc.c
+++ b/tests/stdlib/alloc.c
@@ -31,7 +31,7 @@ void test_valid_aligned(void *ptr, size_t alignment, int error_val) {
      * address. */
     uintptr_t ptr_alignment_rem = (uintptr_t)ptr % (uintptr_t)alignment;
     
-    if (ptr_alignment_rem == 0) {
+    if (ptr != NULL && ptr_alignment_rem == 0) {
         // Constant output for successful case
         printf("pointer: (alignment OK), ");
     }