mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 18:22:09 +02:00
Ensure usage of __attribute__(cleanup) never frees un-initialized memory
Use macros that take an initializer parameter to, thereby ensuring the variable to be cleaned up is always initialized.
This commit is contained in:
@@ -26,7 +26,7 @@ serialize_string_tuple(PyObject *src) {
|
||||
const char *pysrc = PyUnicode_AsUTF8(PyTuple_GET_ITEM(src, i));
|
||||
if (!pysrc) {
|
||||
PyErr_Clear();
|
||||
DECREF_AFTER_FUNCTION PyObject *u8 = PyUnicode_AsEncodedString(PyTuple_GET_ITEM(src, i), "UTF-8", "ignore");
|
||||
RAII_PyObject(u8, PyUnicode_AsEncodedString(PyTuple_GET_ITEM(src, i), "UTF-8", "ignore"));
|
||||
if (!u8) { PyErr_Print(); fatal("couldn't parse command line"); }
|
||||
ans[i] = calloc(PyBytes_GET_SIZE(u8) + 1, sizeof(char));
|
||||
if (ans[i] == NULL) fatal("Out of memory");
|
||||
|
||||
Reference in New Issue
Block a user