1. memory leak: ob_refcnt of new ref from call to PyObject_CallMethod is 1 too high

    Report

    1
    static int
    CTracer_init(CTracer *self, PyObject *args_unused, PyObject *kwds_unused)
    {
    int ret = RET_ERROR;
    PyObject * weakref = NULL;
    #if COLLECT_STATS
    self->stats.calls = 0;
    self->stats.lines = 0;
    self->stats.returns = 0;
    self->stats.exceptions = 0;
    self->stats.others = 0;
    self->stats.new_files = 0;
    self->stats.missed_returns = 0;
    self->stats.stack_reallocs = 0;
    self->stats.errors = 0;
    #endif /* COLLECT_STATS */
    self->should_trace = NULL;
    self->check_include = NULL;
    self->warn = NULL;
    self->concur_id_func = NULL;
    self->data = NULL;
    self->plugin_data = NULL;
    self->should_trace_cache = NULL;
    self->arcs = NULL;
    self->started = 0;
    self->tracing_arcs = 0;
    if (DataStack_init(self, &self->data_stack)) {
    goto error;
    }
    weakref = PyImport_ImportModule("weakref");
    if (weakref == NULL) {
    STATS( self->stats.errors++; )
    goto error;
    }
    self->data_stack_index = PyObject_CallMethod(weakref, "WeakKeyDictionary", NULL);
    Py_XDECREF(weakref);
    if (self->data_stack_index == NULL) {
    STATS( self->stats.errors++; )
    goto error;
    }
    self->data_stacks = NULL;
    self->data_stacks_alloc = 0;
    self->data_stacks_used = 0;
    self->pdata_stack = &self->data_stack;
    self->cur_entry.file_data = NULL;
    self->cur_entry.last_line = -1;
    self->last_exc_back = NULL;
    ret = RET_OK;
    goto ok;
    error:
    STATS( self->stats.errors++; )
    ok:
    return ret;
    }
    1. when considering value == (int)0 from coverage/tracer.c:202

      taking False path

    2. when PyImport_ImportModule() succeeds

    3. taking False path

    4. when PyObject_CallMethod() succeeds

      new ref from call to PyObject_CallMethod was allocated at: self->data_stack_index = PyObject_CallMethod(weakref, "WeakKeyDictionary", NULL);

    5. taking False path

      when taking True path

    6. taking False path

    7. returning

      was expecting final owned ob_refcnt of new ref from call to PyObject_CallMethod to be 0 since nothing references it but final ob_refcnt is refs: 1 owned

      found 1 similar trace(s) to this