realloc2.c revision e739ac0589b4fb43561f801c4faba8c1b89f8680
1/* This test demonstrated an obscure bug in malloclists handling caused by
2   multiple blocks hashing to the same list and one being overwritten at
3   realloc time due to bad ordering of the things happening.  Now runs
4   without error. */
5
6#include <stdlib.h>
7#include <stdio.h>
8
9int main ( void )
10{
11  char* p;
12  int i;
13  for (i = 0; i < 10000; i++) {
14    p = malloc(10 + 10 * (i % 100));
15    p = realloc(p, 500);
16    p = realloc(p, 600);
17    free(p);
18  }
19  return 0;
20}
21
22