This is our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

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

tlann
76121419
accept rate: 100%


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).

permanent link

answered 19 Oct '13, 09:14

Pascal%20Quantin's gravatar image

Pascal Quantin
5.5k1060
accept rate: 30%

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

(19 Oct '13, 15:22) tlann
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×637
×173
×2

question asked: 18 Oct '13, 16:38

question was seen: 3,298 times

last updated: 19 Oct '13, 15:22

p​o​w​e​r​e​d by O​S​Q​A