X-Git-Url: http://git.droids-corp.org/?p=protos%2Flibecoli.git;a=blobdiff_plain;f=src%2Fecoli_malloc.c;h=bd8678d17bb0f4bae9291d0102b23125094df7f5;hp=5a022ae9c1a75c2ed28f77f1c459b489342ff3cc;hb=HEAD;hpb=18d03456d96f7a086a2ccc82ce97fcf056848d90 diff --git a/src/ecoli_malloc.c b/src/ecoli_malloc.c index 5a022ae..bd8678d 100644 --- a/src/ecoli_malloc.c +++ b/src/ecoli_malloc.c @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -149,7 +150,7 @@ static int ec_malloc_testcase(void) return -1; memset(ptr, 0, 10); ptr2 = ec_realloc(ptr, 20); - EC_TEST_CHECK(ptr2 != NULL, "cannot realloc ptr\n"); + testres |= EC_TEST_CHECK(ptr2 != NULL, "cannot realloc ptr\n"); if (ptr2 == NULL) ec_free(ptr); else @@ -164,8 +165,11 @@ static int ec_malloc_testcase(void) ec_free_func(ptr); ptr = NULL; - ptr = ec_calloc(2, (size_t)-1); - EC_TEST_CHECK(ptr == NULL, "bad overflow check in ec_calloc\n"); + /* here we use atoll() instead of a constant because we want to + * prevent the compiler to check the overflow at compilation + * time */ + ptr = ec_calloc(3, atoll("9223372036854775807")); /* (1 << 63) - 1 */ + testres |= EC_TEST_CHECK(ptr == NULL, "bad overflow check in ec_calloc\n"); return testres; }