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_parallel.c

    r5c07bfe re375e0f  
    21602160        trace->hasher_type = type;
    21612161        if (hasher) {
     2162                if (trace->hasher_owner == HASH_OWNED_LIBTRACE) {
     2163                        if (trace->hasher_data) {
     2164                                free(trace->hasher_data);
     2165                        }
     2166                }
    21622167                trace->hasher = hasher;
    21632168                trace->hasher_data = data;
     2169                trace->hasher_owner = HASH_OWNED_EXTERNAL;
    21642170        } else {
    21652171                trace->hasher = NULL;
    21662172                trace->hasher_data = NULL;
     2173                trace->hasher_owner = HASH_OWNED_LIBTRACE;
    21672174        }
    21682175
Note: See TracChangeset for help on using the changeset viewer.