Changeset e375e0f for lib/trace.c


Ignore:
Timestamp:
02/28/18 15:11:24 (3 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
cachetimestamps, develop, etsilive, master, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance
Children:
e4eaca5
Parents:
5c07bfe
Message:

Fix bug where libtrace-created hasher_data was leaked.

If trace_set_hasher was called with a null hasher, libtrace
would malloc memory for storing hasher_data. However, that
memory was never freed, since we had no way of telling whether
that memory had been externally allocated and passed in to
trace_set_hasher or if the memory had been allocated by libtrace.

Added a flag to the libtrace_t structure that records who owns
hasher_data and will now free it during trace_destroy if the
memory was allocated by libtrace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    r9375d2e re375e0f  
    271271        libtrace->hasher = NULL;
    272272        libtrace->hasher_data = NULL;
     273        libtrace->hasher_owner = HASH_OWNED_EXTERNAL;
    273274        libtrace_zero_ocache(&libtrace->packet_freelist);
    274275        libtrace_zero_thread(&libtrace->hasher_thread);
     
    738739        }
    739740
     741        if (libtrace->hasher_owner == HASH_OWNED_LIBTRACE) {
     742                if (libtrace->hasher_data) {
     743                        free(libtrace->hasher_data);
     744                }
     745        }
     746
     747
    740748        if (libtrace->perpkt_cbs)
    741749                trace_destroy_callback_set(libtrace->perpkt_cbs);
Note: See TracChangeset for help on using the changeset viewer.