Uploaded image for project: 'Couchbase Python Client Library'
  1. Couchbase Python Client Library
  2. PYCBC-1383

Fix memory leak in build_kv_error_map_info when building KV exception

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 4.0.3
    • 4.0.0, 4.0.1, 4.0.2
    • None
    • None
    • 1

    Description

      When building the KV error map, build_kv_error_map_info(), creates two memory leaks by adding strings directly to the err_info dict using the PyDict_SetItemString().

      To fix the leak:

      1. created a PyObject* that stores the string
      2. add the created PyObject* to the err_info dict
      3. decrement the created PyObject* after it has been added to the dict

      Leak:

          if (-1 == PyDict_SetItemString(err_info, "name", PyUnicode_FromString(error_info.name.c_str()))) {
              PyErr_Print();
              PyErr_Clear();
          }
          if (-1 == PyDict_SetItemString(err_info, "description", PyUnicode_FromString(error_info.description.c_str()))) {
              PyErr_Print();
              PyErr_Clear();
          }
      

      Also, call tp_free() in the exception_base destructor (see associated ticket PYCBC-1382).

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              jared.casey Jared Casey
              jared.casey Jared Casey
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty