Explorar o código

Add test of calloc with overflow

Peter Limkilde Svendsen %!s(int64=6) %!d(string=hai) anos
pai
achega
8b7453edf2
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      tests/stdlib/alloc.c

+ 4 - 0
tests/stdlib/alloc.c

@@ -18,6 +18,10 @@ int main(int argc, char ** argv) {
     }
     free(ptrc);
 
+    char * ptrco = (char *)calloc(SIZE_MAX, SIZE_MAX);
+    printf("calloc (overflowing) %p\n", ptrco);
+    free(ptrco); /* clean up correctly even if overflow is not handled */
+
     char * ptra = (char *)memalign(256, 256);
     printf("memalign %p\n", ptra);
     for(i = 0; i < 256; i++) {