<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Bernd,<div><br></div><div>The latest analyzer should warn about double frees.</div><div><br></div><div>The code you provided does not compile, but the analyzer warns on this fixed code snippet:</div><div><div>class my_object_t {};</div><div>void foo(my_object_t *obj) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>delete obj;</div><div>}</div><div>int foo2() {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>my_object_t *obj = new my_object_t;<span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if (!obj)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return -1;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>foo(obj);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>delete obj;</div><div>}</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><b>/Users/zaks/tmp/ex.cpp:10:2: </b><span style="color: #d53bd3"><b>warning: </b></span><b>Attempt to free released memory</b></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> delete obj;</div></div><div><br></div><div>Cheers,</div><div>Anna.</div><div><div>On Aug 2, 2013, at 5:09 AM, Bernd Schubert <<a href="mailto:bernd.schubert@itwm.fraunhofer.de">bernd.schubert@itwm.fraunhofer.de</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hi all,<br><br>is there some way to instruct the static analyzer to check for double deleted objects?<br><br><br>void foo(my_object_t obj)<br>{<br><span class="Apple-tab-span" style="white-space: pre;"> </span>delete obj;<br>}<br><br>main()<br>{<br><span class="Apple-tab-span" style="white-space: pre;"> </span>my_object_t *obj = new my_object_t;<br><span class="Apple-tab-span" style="white-space: pre;"> </span><br><span class="Apple-tab-span" style="white-space: pre;"> </span>if (!obj)<br><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>return -1;<br><br><span class="Apple-tab-span" style="white-space: pre;"> </span>foo(obj);<br><br><span class="Apple-tab-span" style="white-space: pre;"> </span>delete obj;<br>}<br><br><br>I just found something like that in my code and the static analyzer hadn't detected it.<br><br><br>Thanks,<br>Bernd<br><br>_______________________________________________<br>cfe-users mailing list<br><a href="mailto:cfe-users@cs.uiuc.edu">cfe-users@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users</a></div></blockquote></div><br></div></body></html>