Wireshark-dev: [Wireshark-dev] Re: Coverity resource leak related question

From: John Thacker <johnthacker@xxxxxxxxx>
Date: Sun, 1 Mar 2026 08:30:54 -0500
On Sun, Mar 1, 2026 at 8:11 AM Tamás Regős <regost@xxxxxxxxx> wrote:
Hi Pascal,

Was there any consideration or discussion about a Coverity model file for these scenarios?

Regards,
Tamas

Hi Tamas,

If someone could do that, it would be welcome.

Complicating the matter somewhat is that the various wmem_() functions would leak memory if the wmem_allocator_t* passed in as the first argument is NULL. (This allocates with g_malloc, etc.) In practice pinfo->pool is never NULL (epan_dissect_init and epan_dissect_reset guarantee this), but if you examine many of the Coverity defect reports they take a branch assuming that the allocator is NULL. It might be necessary to do something like replace pinfo->pool with a macro that expands to simply pinfo->pool not on Coverity but to something that guarantees a non-NULL on Coverity, although that might not be sufficient.

Simply ignoring all the resource leaks would be a problem in the cases where those functions are called with NULL.

Cheers,
John