Changeset 5fe998b


Ignore:
Timestamp:
01/08/19 10:09:47 (22 months ago)
Author:
Shane Alcock <salcock@…>
Branches:
develop
Children:
4ac48fa
Parents:
2bce91d
Message:

Make sure we zero any filter structures we allocate

This fixes "uninitialised bytes" warnings that we get from
valgrind whenever filters are used with ring:

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/format_linux_common.c

    r630460b r5fe998b  
    7373         * deletion causing the filter to no longer work */
    7474        f = (libtrace_filter_t *) malloc(sizeof(libtrace_filter_t));
     75        memset(f, 0, sizeof(libtrace_filter_t));
    7576        memcpy(f, filter, sizeof(libtrace_filter_t));
    7677        f->filterstring = strdup(filter->filterstring);
  • lib/trace.c

    rd439067 r5fe998b  
    15541554#else
    15551555        struct libtrace_filter_t *filter = (struct libtrace_filter_t *)
    1556                 malloc(sizeof(struct libtrace_filter_t));
     1556                calloc(1, sizeof(struct libtrace_filter_t));
    15571557        filter->filter.bf_insns = (struct bpf_insn *)
    15581558                malloc(sizeof(struct bpf_insn) * bf_len);
     
    15781578#ifdef HAVE_BPF
    15791579        libtrace_filter_t *filter = (libtrace_filter_t*)
    1580                                 malloc(sizeof(libtrace_filter_t));
     1580                                calloc(1, sizeof(libtrace_filter_t));
    15811581        filter->filterstring = strdup(filterstring);
    15821582        filter->jitfilter = NULL;
Note: See TracChangeset for help on using the changeset viewer.