Wireshark-dev: [Wireshark-dev] register_tap_listener memleak

From: Peter Wu <peter@xxxxxxxxxxxxx>
Date: Thu, 15 Mar 2018 13:24:24 +0100
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? 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