mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-106843: fix memleak in _PyCompile_CleanDoc (#106846)
This commit is contained in:
parent
1e36ca63f9
commit
ece3b9d12a
1 changed files with 4 additions and 1 deletions
|
@ -2267,6 +2267,7 @@ compiler_function_body(struct compiler *c, stmt_ty s, int is_async, Py_ssize_t f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (compiler_add_const(c->c_const_cache, c->u, docstring ? docstring : Py_None) < 0) {
|
if (compiler_add_const(c->c_const_cache, c->u, docstring ? docstring : Py_None) < 0) {
|
||||||
|
Py_XDECREF(docstring);
|
||||||
compiler_exit_scope(c);
|
compiler_exit_scope(c);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
@ -8060,7 +8061,9 @@ _PyCompile_CleanDoc(PyObject *doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_DECREF(doc);
|
Py_DECREF(doc);
|
||||||
return PyUnicode_FromStringAndSize(buff, w - buff);
|
PyObject *res = PyUnicode_FromStringAndSize(buff, w - buff);
|
||||||
|
PyMem_Free(buff);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue