Browse Source

Add test of calloc with overflow

Peter Limkilde Svendsen 6 năm trước cách đây
mục cha
commit
8b7453edf2
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  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++) {