This is a static archive of our old Q&A Site. Please post any new questions and answers at

STATUS_ACCESS_VIOLATION: dissector accessed an invalid memory address when calling g_free


I have the following lines in a plugin dissector. The call to g_free below results in a "STATUS_ACCESS_VIOLATION: dissector accessed an invalid memory address." Looking at the memory address of pchar1 it looks valid and holds a a short string string.

Looking deeper into get_CDR_octet_seq I can see that it allocates memory using ep_alloc_array0. However, the documentation of this function states "Caller of this function must remember to free the array pointed to by seq."

It looks like the code changed from 1.8 to 1.10. Should I file a bug report on the need for the code comments to change?

gchar *pchar1=NULL;
gchar *pchar2=NULL;

get_CDR_octet_seq(tvb,&pchar1,&offset,4); pchar2=make_printable_string(pchar1,4); g_free(pchar1);

asked 18 Oct ‘13, 16:38

tlann's gravatar image

accept rate: 100%

One Answer:


You are right the function was changed in revision 4498 for bug 3725 but the comment was not updated accordingly.

I checked in updated comments in revision 52690 and in your code you just need to remove the g_free call (ephemeral memory will be automatically freed once the packet dissection is done).

answered 19 Oct '13, 09:14

Pascal%20Quantin's gravatar image

Pascal Quantin
accept rate: 30%

Thanks. I kinda figured out I needed to remove g_free. ;-)

(19 Oct '13, 15:22) tlann