]> andersk Git - splint.git/blob - test/malloc.c
Made allocations involving sizeof work correctly (test/malloc.c).
[splint.git] / test / malloc.c
1 void f1 ()
2 {
3   int *ip = (int *) malloc (89); /* not divisible */
4   if (ip != NULL) {
5     ip[88]=23; /* out of range */
6     free (ip);
7   }
8 }
9
10 void f2 ()
11 {
12   int *ip = (int *) malloc (88); /* divisible okay */
13   if (ip != NULL) {
14     ip[21]=23; /* okay */
15     ip[22]=23; /* bad */
16     free (ip);
17   }
18 }
19
20 void f3 ()
21 {
22   int *ip = (int *) malloc (87 * sizeof (int)); 
23   if (ip != NULL) {
24     ip[21]=23; /* okay */
25     ip[86]=23; /* okay */
26     ip[87]=23; /* bad */
27     free (ip);
28   }
29 }
30
31 void f4 ()
32 {
33   int *ip = (int *) malloc (87 * sizeof (short)); /* not divisible */
34   if (ip != NULL) {
35     ip[86]=23; /* bad */
36     free (ip);
37   }
38 }
This page took 0.04492 seconds and 5 git commands to generate.