Sorry for the delayed response. This is indeed expected behavior.
The path analysis in the static analyzer involves essentially unrolling loops a finite number of times. To ensure analysis termination, once a threshold is reached (3 iterations) the analysis of a given path is halted. Since the reference to 'array' is live within the loop body, no leak is reported since we do not reach a point in the path where that reference is no longer live.
Fixing this requires gradually improving the analysis of loops, e.g., by increasing the termination threshold for loops of a fixed bound. Changing the handling of loops in the analyzer, however, needs to be done with care as it can substantially effect analysis performance (with a tradeoff of bugs found/missed). It's something I think deserves more attention in the future.
On Dec 31, 2009, at 12:01 AM, Cristian Draghici wrote: