Bernd,

The latest analyzer should warn about double frees.

The code you provided does not compile, but the analyzer warns on this fixed 
code snippet:
class my_object_t {};
void foo(my_object_t *obj) {
        delete obj;
}
int foo2() {
        my_object_t *obj = new my_object_t;     
        if (!obj)
                return -1;
        foo(obj);
        delete obj;
}

/Users/zaks/tmp/ex.cpp:10:2: warning: Attempt to free released memory
        delete obj;

Cheers,
Anna.
On Aug 2, 2013, at 5:09 AM, Bernd Schubert <[email protected]> 
wrote:

> Hi all,
> 
> is there some way to instruct the static analyzer to check for double deleted 
> objects?
> 
> 
> void foo(my_object_t obj)
> {
>       delete obj;
> }
> 
> main()
> {
>       my_object_t *obj = new my_object_t;
>       
>       if (!obj)
>               return -1;
> 
>       foo(obj);
> 
>       delete obj;
> }
> 
> 
> I just found something like that in my code and the static analyzer hadn't 
> detected it.
> 
> 
> Thanks,
> Bernd
> 
> _______________________________________________
> cfe-users mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users

_______________________________________________
cfe-users mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users

Reply via email to