Wireshark-dev: Re: [Wireshark-dev] register_tap_listener memleak
From: Pascal Quantin <pascal.quantin@xxxxxxxxx>
Date: Thu, 15 Mar 2018 13:39:55 +0100
Hi Peter,

2018-03-15 13:24 GMT+01:00 Peter Wu <peter@xxxxxxxxxxxxx>:
Hey Dario, Pascal and others,

I was looking at memleaks as reported by LSAN while running the
decryption test suite, there are quite a number of occurrences.

One of them is tap (return value of register_tap_listener) which is a
GString which seems unnecessary since it is an error message which the
caller should not have to modify. Dario tried to convert that to a gchar
before in https://code.wireshark.org/review/15270 but that particular
patch was reverted in v2.1.1rc0-197-ga383e692c8.

Pascal tried again in https://code.wireshark.org/review/16053, but
somehow it also got stuck. Before trying to touch this again, is there
something to be aware of?

As far as I can remember this was a rebase of Dario's work with the most important bug (plugins not working anymore) fixed.
I was personally not a fan of this refactoring (see my initial comments in teh patch set for the list of issues I saw by that time)
and did not push it further. It was here in case someone wanted to use it as a starting point, so feel free to revive it :)
 
I just want to modify register_tap_listener:

- Change GString to char *
- Either use NULL wmem scope or use g_strdup_printf.
- Add G_GNUC_WARN_UNUSED_RESULT such that callers will not accidentally
  leak any error messages.
- Modify callers such that they do check the error. (g_warning?)

FWIW, the original error in question is:

  register_tap_listener("ip", &tap_ip_enabled, NULL, TL_REQUIRES_NOTHING, NULL, ip_tap_pkt, NULL);
  // leaks: g_string_printf(error_string, "Tap %s not found", tapname);
--
Kind regards,
Peter Wu
https://lekensteyn.nl
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@wireshark.org?subject=unsubscribe