guy 2001/08/28 02:19:48 CDT
Modified files:
. packet-giop.c
Log:
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
Revision Changes Path
1.48 +154 -84 ethereal/packet-giop.c