Changeset fd4482d for lib/trace.c


Ignore:
Timestamp:
03/09/16 09:19:43 (5 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, master, ndag_format, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
38c00dd, c46b7ea
Parents:
b6cbdaf
Message:

Make sure trace_create_packet() doesn't segfault

If allocating memory for the new packet fails, we now return NULL
instead of carrying on and trying to initialise the packet fields.

This has always been the intended behaviour (see some of the examples
for cases where we check if packet is NULL after calling trace_create_packet())
but I guess nobody actually implemented it...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    r7d1ada1 rfd4482d  
    638638                (libtrace_packet_t*)calloc((size_t)1,sizeof(libtrace_packet_t));
    639639
     640        if (packet == NULL)
     641                return NULL;
     642
    640643        packet->buf_control=TRACE_CTRL_PACKET;
    641644        trace_clear_cache(packet);
Note: See TracChangeset for help on using the changeset viewer.