| 1 |
/* { dg-skip-if "requires hosted libstdc++ for stdlib calloc" { ! hostedlib } } */ |
| 2 |
|
| 3 |
#include <stdlib.h> |
| 4 |
#include <string.h> |
| 5 |
|
| 6 |
typedef unsigned char Byte; |
| 7 |
typedef unsigned int uInt; |
| 8 |
typedef unsigned long uLong; |
| 9 |
|
| 10 |
#define Z_NULL 0 |
| 11 |
|
| 12 |
int test () |
| 13 |
{ |
| 14 |
uLong comprLen = 10000*sizeof(int); |
| 15 |
uLong uncomprLen = comprLen; |
| 16 |
Byte *compr = (Byte*)calloc((uInt)comprLen, 1); |
| 17 |
Byte *uncompr = (Byte*)calloc((uInt)uncomprLen, 1); |
| 18 |
if (compr == Z_NULL || uncompr == Z_NULL) |
| 19 |
{ |
| 20 |
return 1; /* { dg-warning "leak of 'uncompr'" "uncompr leak" } */ |
| 21 |
/* { dg-warning "leak of 'compr'" "compr leak" { target *-*-* } .-1 } */ |
| 22 |
} |
| 23 |
strcpy((char*)uncompr, "garbage"); |
| 24 |
return 0; /* { dg-warning "leak of 'uncompr'" "uncompr leak" } */ |
| 25 |
/* { dg-warning "leak of 'compr'" "compr leak" { target *-*-* } .-1 } */ |
| 26 |
} |