In function add_vendor the below code gets executed if vendor info was already there. Why when a pointer is freed after a valid vendor info is found, g_free() crashing?
We are seeing crash when g_free is called.
asked 23 Apr '15, 11:14 universini edited 23 Apr '15, 15:41 |
One Answer:
[Updated after noticing this was Radius not Diameter--oops!] Well, looking at the code it appears that:
This code is different in the current development version--and it was changed to fix a crash (see change 5265). You've got a couple options:
answered 23 Apr '15, 13:49 JeffMorriss ♦ edited 23 Apr '15, 13:56 showing 5 of 7 show 2 more comments |
Ok, if it has already found vendor that means it has a valid vendor name right? Why g_free has to crash when freeing a valid pointer? Is it a good idea to replace char * with a static array?
It's not clear why it's crashing. Note that glib should actually be printing something (to stderr) to explain what's wrong with the free though that may not help explain too much.
The problem with a static char array is it's more restrictive: what happens if your vendor name is too long (Wireshark currently has a Diameter vendor whose name is "NokiaSolutionsAndNetworks").
As mentioned, the crash may be related to the fix described or it may not. But I don't think it's worth spending a lot of time investigating such an ancient version, especially when there's a simple solution: don't have a duplicated vendor.
If it crashes in the currently-supported versions and/or development version then it would be worth investigating (I tried it with a duplicated VENDOR line and it worked fine--Valgrind didn't complain either).
It says Abort with signal 6
By the way, I am confused with .l and .c versions of the same file. From my understanding it looks like changes should only be done in .l file and .c will be automatically generated when built. Is that right? or don't we care .c at all?
It's a (f)lex parser. So humans write the .l file which (f)lex turns into the .c file which the compiler turns into an object file.
We (humans) don't need to worry about the .c file--unless you're working on the build system (Makefiles).
So always make changes in .l file and make sure new .c file is generated with latest changes, right? If .c file isn't recreated with new changes, then changes won't work. Is that the way it is?
Correct.
Correct.
Yes.