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

Wireshark-bugs: [Wireshark-bugs] [Bug 5203] Lua: Must expose pinfo.private_data as ByteArray of

Date: Tue, 18 Oct 2011 18:21:38 -0700 (PDT)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5203

Tony Trinh <tony19@xxxxxxxxx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tony19@xxxxxxxxx

--- Comment #2 from Tony Trinh <tony19@xxxxxxxxx> 2011-10-18 21:21:37 EDT ---
(In reply to comment #1)
I don't think this bug should be marked as fixed....

IMO, this new 'private' field is more trouble than it's worth (due to the
potential bugs in the C glue), and there's not much value in passing around an
array of strings. Lua affords us a different (and perhaps cleaner) way of
achieving the same thing by creating a dictionary that uses a packet-unique
field as a key  (such as frame number).

I haven't had a chance to study your code changes in depth, but I think I see a
few problems already.

1. There's a memory leak at line 834. You're returning w/o freeing the string
allocated a few lines before.
http://anonsvn.wireshark.org/viewvc/trunk/epan/wslua/wslua_pinfo.c?revision=39461&view=markup#l834

2. PrivateTable:__gc (and some/all of the other garbage collectors in
wslua_pinfo.c)
Lua only calls __gc for an object right before it's about to collect that
object, 
and that only ever happens *once* for any object. You only have 1 chance to do
any necessary cleanup. Anything missed is considered a leak. So, the fact that
allocated objects are only freed on the condition of an "expired" flag is a bit
troubling. You probably see something I don't.   (I think this function is a
pattern copied from elsewhere in the file)

3. It looks like the PrivateTable stores a pointer to a string from the Lua
stack (which will eventually point to garbage).

-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are watching all bug changes.