bpo-34080: Fix memory leak on parsing error by vstinner · Pull Request #8242 · python/cpython

serhiy-storchaka

* bpo-34080, bpo-34084: err_free() now always releases 'text' memory
  allocated by PyObject_Malloc() to fix a memory leak on parsing
  error.  Previously, err->text was not released (by err_input()) on
  E_ERROR error.
* Remove also "with Barry as BDFL, use '<>' instead of '!='" static
  string error message (previously set to err_ret->text) because in
  practice, err_ret->text is always set later. Add also an assertion
  to make sure that err_ret->text is only set once.
* Replace old PyObject_MALLOC() and PyObject_FREE() aliases with
  PyObject_Malloc() and PyObject_Free() function calls.

Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
Co-Authored-By: Xiang Zhang <angwerzx@126.com>

@vstinner vstinner changed the title bpo-34080: Fix memory leak in err_clear() bpo-34080: Fix memory leak on parsing error

Jul 11, 2018

@vstinner

zhangyangyu

serhiy-storchaka