Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Question regarding emem -> wmem conversion

From: Dario Lombardo <dario.lombardo.ml@xxxxxxxxx>
Date: Fri, 13 Sep 2013 15:42:24 +0200
I've submitted a patch with epan scope.


On Fri, Sep 13, 2013 at 2:30 PM, Evan Huus <eapache@xxxxxxxxx> wrote:
On 2013-09-13, at 7:55 AM, Dario Lombardo <dario.lombardo.ml@xxxxxxxxx> wrote:

> I'm trying to address se_alloc() calls. If I change this:
>
> Index: packet-infiniband_sdp.c
> ===================================================================
> --- packet-infiniband_sdp.c   (revision 52002)
> +++ packet-infiniband_sdp.c   (working copy)
> @@ -31,6 +31,7 @@
>  #include <epan/packet.h>
>  #include <epan/prefs.h>
>  #include <epan/conversation.h>
> +#include <epan/wmem/wmem.h>
>  #include <stdlib.h>
>  #include <errno.h>
>
> @@ -529,8 +530,8 @@
>          heur_dissector_add("infiniband.mad.cm.private", dissect_ib_sdp, proto_ib_sdp);
>
>          /* allocate enough space in the addresses to store the largest address (a GID) */
> -        manual_addr_data[0] = se_alloc(GID_SIZE);
> -        manual_addr_data[1] = se_alloc(GID_SIZE);
> +        manual_addr_data[0] = wmem_alloc(wmem_file_scope(), GID_SIZE);
> +        manual_addr_data[1] = wmem_alloc(wmem_file_scope(), GID_SIZE);
>
>          initialized = TRUE;
>      }
> @@ -567,4 +568,3 @@
>
>      }
>  }
> -
>
> tshark -v crashes. What is wrong with my patch?

Apparently there is no file in scope when that code is run. Depending on the necessary lifetime of the memory, it may make sense to replace it with epan scoped memory (the lifetime of the program, basically) or manually managed memory if the lifetime is something else.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe