Why are you freeing b in foo?<p>It&#x27;s confusing if you&#x27;re mallocing in one scope and freeing it in another one (foo is <i>especially</i> confusing, besides being a disaster ready to happen). But if you write bar() like this:<p><pre><code>    void bar() {
        char *b = malloc(123);

        foo(b);

        free(b);
        b = NULL;
    }
</code></pre>
it looks all right.<p>Not that I&#x27;m advocating this kind of use. I have... mixed feelings about it. But I&#x27;ve seen it used and it doesn&#x27;t have to be confusing.<p>Its primary merit is that it makes use-after-free cases immediately obvious, since they&#x27;re going to trigger a segfault.<p>But there are better ways to achieve that.