<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Report false positive leak of memory"
   href="https://llvm.org/bugs/show_bug.cgi?id=26691">26691</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Report false positive leak of memory
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.8
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>analyze
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tony@airtame.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>OSX 10.11.3
checker-278
clang version 3.8.0

A function is used to post a message in a priority queue. The thread dequeuing
the message is freeing it with "free(message);". Scan-build report no error
when the message is enqueued in the body of the function that allocated it but
report a problem if the message is enqueued by another function. An example is
illustrated below.

------

Example 1:
// No problem reported

int32_t send_message(void *data, void *message_queue)
{
    Msg_t *message = calloc(1, sizeof(Msg_t));
    message->type = MSG_TYPE_SEND_MESSAGE;
    message->data[0] = data;

    mq_enqueue_message(message_queue, PRIORITY_HIGH, (void *)message);
    return OK;
}

------

Example 2:
// Potential leak of memory pointed to by 'message'

int32_t send_message(void *data, void *message_queue)
{
    Msg_t *message = calloc(1, sizeof(Msg_t));
    message->type = MSG_TYPE_SEND_MESSAGE;
    message->data[0] = data;

    return enqueue(message, message_queue);
}

int32_t enqueue(Msg_t *message, void *message_queue)
{
    mq_enqueue_message(message_queue, PRIORITY_HIGH, (void *)message);
    return OK;
}

------</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>