<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 31, 2013, at 5:21 , Branden Archer <<a href="mailto:b.m.archer4@gmail.com">b.m.archer4@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>Basically, you need to pass a pointer which we are tracking to a 
function call indirectly (ex: as a field in a struct..). You should pass
 it to a function which is known not to free memory or close stream. 
Finally, you leak that resource/pointer.</div><div><br></div><div>Previously, we would have a false negative - no leak would be reported. Now, we should be catching the leak.</div></blockquote><br>Ah, got you. See the first attached patch for these added cases.<br>
<br>- Branden<br></blockquote></div><div><br></div><div><div>+void testPassConstPointerIndirectly() {</div><div>+  struct HasPtr hp;</div><div>+  hp.p = fopen("myfile.txt", "w");</div><div>+  fputc(0, (FILE *)&hp);</div><div>+  return; // expected-warning {{Opened file is never closed; potential resource leak}}</div><div>+}</div></div><div><br></div><div>Heh. Did you really want this test case? It's not actually valid (&hp is a FILE**, not a FILE*):</div><div><br></div><div><br></div><div>A few remaining comments for the MallocChecker patch:</div><div><br></div><div><div>+  if (ExplodedNode *N = C.generateSink()) {</div></div><div><br></div><div>Please use an early return here.</div><div><br></div><div><br></div><div><div>+    int offsetBytes = Offset.getOffset()/C.getASTContext().getCharWidth();</div></div><div><br></div><div><i>Very</i> nitpicky, but can you put spaces around the /?</div><div><br></div><div><br></div><div><div>+       << ((abs(offsetBytes) > 1) ? "bytes" : "byte")</div></div><div><br></div><div>Perfect!</div><div><br></div><div>Jordan</div></body></html>