diff --git a/include/set_asserts.h b/include/set_asserts.h index 32d9209..c65a2a6 100644 --- a/include/set_asserts.h +++ b/include/set_asserts.h @@ -28,8 +28,9 @@ if (exp != act) \ { \ test->passed = false; \ - test->error_msg = format_string( \ - "Expected %d to be %d\n Failed with message: " msg, act, exp); \ + test->error_msg = \ + format_string("Expected %d to be %d\n Failed with message: %s", \ + act, exp, msg); \ return; \ } diff --git a/src/list.c b/src/list.c index e182b59..b45e0bc 100644 --- a/src/list.c +++ b/src/list.c @@ -28,8 +28,11 @@ struct SETBlockMeta *set_ll_free_one(struct SETBlockMeta *head, void *address) if (meta == head) { struct SETBlockMeta *ret = meta->next; - ret->prev = NULL; - ret->end = meta->end; + if (ret) + { + ret->prev = NULL; + ret->end = meta->end; + } free(meta); return ret; } diff --git a/src/utils.c b/src/utils.c index 1a693a5..a3266c1 100644 --- a/src/utils.c +++ b/src/utils.c @@ -15,7 +15,7 @@ char *format_string(const char *fmt, ...) va_list args; va_start(args, fmt); size_t size = vsnprintf(NULL, 0, fmt, args); - char *out = (char *)malloc(size + 1); + char *out = (char *)set_malloc(size + 1); if (!out) { diff --git a/testtest.c b/testtest.c index 3d875c8..8ab5800 100644 --- a/testtest.c +++ b/testtest.c @@ -61,6 +61,7 @@ TEST(Other_Basic) TEST(Other_With_Malloc) { int *some_array = set_malloc(20 * sizeof(int)); + int *array = set_malloc(20); for (int i = 0; i < 20; i++) { @@ -73,6 +74,9 @@ TEST(Other_With_Malloc) } fprintf(stdout, ".\n"); + set_free(array); + set_free(some_array); + ASSERT_TRUE(false); }