1. memory leak: ob_refcnt of '*quoted' is 1 too high

    Report

    1
    static PyObject *
    _mysql_escape_dict(
    PyObject *self,
    PyObject *args)
    {
    PyObject *o=NULL, *d=NULL, *r=NULL, *item, *quoted, *pkey;
    Py_ssize_t ppos = 0;
    if (!PyArg_ParseTuple(args, "O!O:escape_dict", &PyDict_Type, &o, &d))
    goto error;
    if (!PyMapping_Check(d)) {
    PyErr_SetString(PyExc_TypeError,
    "argument 2 must be a mapping");
    return NULL;
    }
    if (!(r = PyDict_New())) goto error;
    while (PyDict_Next(o, &ppos, &pkey, &item)) {
    quoted = _escape_item(item, d);
    if (!quoted) goto error;
    if (PyDict_SetItem(r, pkey, quoted)==-1) goto error;
    Py_DECREF(quoted);
    }
    return r;
    error:
    Py_XDECREF(r);
    return NULL;
    }
    1. was expecting final owned ob_refcnt of '*quoted' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned

      found 7 similar trace(s) to this

    2. when PyArg_ParseTuple() succeeds

      taking False path

    3. when considering range: -0x80000000 <= value <= -1

      taking False path

    4. when PyDict_New() succeeds

      taking False path

    5. when considering range: -0x80000000 <= value <= -1

      taking True path

    6. when _escape_item() succeeds

      '*quoted' was allocated at: quoted = _escape_item(item, d);

    7. taking False path

    8. when treating unknown struct PyObject * * from _mysql.c:1276 as non-NULL

      when PyDict_SetItem() fails

      taking True path

    9. taking False path

      when taking True path