3 void g(/*@temp@*/ int *y
);
5 /*@truenull@*/ bool ptrpred (/*@out@*/ /*@null@*/ int *x
)
7 return (x
== NULL
); /* new error detected by out undef */
10 /*@only@*/ int *f(/*@null@*/ int *x
)
12 int *y
= (int *)malloc (sizeof (int));
19 if (!x
) { return x
; /* 1. Unqualified storage returned as only: x,
20 ** 2. Possibly null storage returned as non-null: x
21 ** 3. Fresh storage y not released before return
25 z
= (int *) malloc (sizeof (int));
26 z2
= (int *)malloc (sizeof (int));
27 z3
= (int *)malloc (sizeof (int));
31 *y
= 3; /* 4. Possible dereference of null pointer: *y */
34 g(z
); /* 5. Possibly null storage passed as non-null param: z
35 ** 6. Passed storage z not completely defined (allocated only): z
37 if (z
) { *z
= 3; } /* okay */
39 if (!z
) { *z
= 3; } /* 7. Possible dereference of null pointer: *z */
40 else { *z
= 4; } /* okay */
42 z4
= (int *)malloc (sizeof (int));
43 if (z4
== NULL
) { *z4
= 3; } /* 8. Possible dereference of null pointer: *z4 */
44 else { free (z4
); } /* [ not any more: 12. Clauses exit... ] */
46 if (!(z2
!= NULL
)) { *z2
= 3; } /* 9. Possible dereference of null pointer: *z2 */
48 if (z3
!= NULL
) { *z3
= 5; /* okay */ }
49 else { *z3
= 3; } /* 10. Possible dereference of null pointer: *z3 */
51 z2
= (int *)malloc (sizeof (int));
53 if (z2
!= NULL
) { *z2
= 5; } ;
55 *z2
= 7; /* 11. Possible dereference of null pointer: *z2 */
57 z5
= (int *) malloc (sizeof (int));
59 if (ptrpred(z5
)) { *z5
= 3; } /* 12. Possible dereference of null pointer: *z5 */
60 if (!ptrpred(z5
)) { *z5
= 3; }
62 if (ptrpred(z5
)) { *z5
= 3; }
67 return z
; /* 13. Fresh storage z3 not released */