Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ EXECUTABLES := \
invalid_aligned_sized_delete_small \
aligned_sized_delete_large \
invalid_aligned_sized_delete_large \
invalid_free_aligned_sized_small \
free_sized_small \
free_sized_large \
unaligned_malloc_usable_size_small \
Expand All @@ -74,6 +75,7 @@ EXECUTABLES := \
malloc_object_size_zero \
invalid_malloc_object_size_small \
invalid_malloc_object_size_small_quarantine \
invalid_malloc_object_size_small_canary \
impossibly_large_malloc \
realloc_init \
calloc_overflow \
Expand Down
8 changes: 8 additions & 0 deletions test/invalid_free_aligned_sized_small.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "../include/h_malloc.h"

int main(void) {
void *p = malloc(16);
// alignment 3 is not a power of two
free_aligned_sized(p, 3, 16);
return 0;
}
11 changes: 11 additions & 0 deletions test/invalid_malloc_object_size_small_canary.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdlib.h>

#include "test_util.h"

size_t malloc_object_size(void *ptr);

OPTNONE int main(void) {
char *p = malloc(16);
// offset past the usable size, into the slab canary region
return (int)malloc_object_size(p + 25);
}
14 changes: 14 additions & 0 deletions test/test_smc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def test_invalid_aligned_sized_delete_large(self):
self.assertEqual(stderr.decode(
"utf-8"), "fatal allocator error: sized deallocation mismatch (large)\n")

def test_invalid_free_aligned_sized_small(self):
_stdout, stderr, returncode = self.run_test(
"invalid_free_aligned_sized_small")
self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode(
"utf-8"), "fatal allocator error: invalid sized deallocation alignment (small)\n")

def test_free_sized_small(self):
_stdout, _stderr, returncode = self.run_test("free_sized_small")
self.assertEqual(returncode, 0)
Expand Down Expand Up @@ -255,6 +262,13 @@ def test_invalid_malloc_object_size_small_quarantine(self):
self.assertEqual(stderr.decode(
"utf-8"), "fatal allocator error: invalid malloc_object_size (quarantine)\n")

def test_invalid_malloc_object_size_small_canary(self):
_stdout, stderr, returncode = self.run_test(
"invalid_malloc_object_size_small_canary")
self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode(
"utf-8"), "fatal allocator error: invalid malloc_object_size (canary)\n")

def test_impossibly_large_malloc(self):
_stdout, stderr, returncode = self.run_test(
"impossibly_large_malloc")
Expand Down