blob: 74d1629f3c735addd6b6a28fa4672a9a3f53445f [file] [log] [blame]
/* C only: C++ exceptions cause a malloc leak after "safer" returns.
Therefore this test has been duplicated as
c-c++-common/analyzer/pr109577-noexcept.c */
void *malloc (unsigned long);
double *
unsafe (unsigned long n)
{
return (double *) malloc (n * sizeof (double));
}
double *
safer (unsigned long n)
{
unsigned long nbytes;
if (__builtin_mul_overflow (n, sizeof (double), &nbytes))
return 0;
return (double *) malloc (nbytes); /* Exceptions enabled cause a leak here. */
}