<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;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 17, 2015, at 1:21 PM, Bob Kuo <<a href="mailto:Bob.Kuo@riverbed.com" class="">Bob.Kuo@riverbed.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class="">Hello clang developers,</div>
<div class=""><br class="">
</div>
<div class="">We recently found a memory leak at work we were not freeing allocated memory returned by the standard C string strdup() function. I ran the static analyzer against a version of the code with the defect and it didn't detect a memory leak. When I reduced
the code to a simpler test case the static analyzer correctly identified the leak. After a few iterations I found that the culprit was a varargs function where the variable that held a reference to the allocated memory was a parameter. With the call to the
varargs function commented out, the static analyzer identified the leak. With the call to the varargs function no warning was produced. </div>
<div class=""><br class="">
</div>
<div class="">Is this a design decision or inherent limit in the static analyzer? Is this a known issue? I didn't see any bugs in the tracker. Should I file a bug?</div>
<div class=""><br class=""></div></div></div></blockquote><br class=""><div>I am not sure if it is related to the function being varargs or just passing the reference to a function the analyzer does not see. Can you check that?</div><div><br class=""></div><div>When a pointer to allocated memory is passed to a function that the analyzer does not see, the analyzer assumes that that function could free it. (This is by design to reduce the number of false positives.)</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class=""><div class="">
</div>
<div class="">Thanks,</div>
<div class=""><br class="">
</div>
<div class="">Bob Kuo</div>
<div class="">
<div id="MAC_OUTLOOK_SIGNATURE" class=""></div>
</div>
</div>
_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@cs.uiuc.edu" class="">cfe-dev@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></body></html>