Dont leak kitty_run_data on error

This commit is contained in:
Kovid Goyal 2022-06-23 08:59:31 +05:30
parent f023f047ff
commit 560b78bc35
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -55,8 +55,8 @@ set_kitty_run_data(RunData *run_data, bool from_source, wchar_t *extensions_dir)
PyObject *ans = PyDict_New();
if (!ans) { PyErr_Print(); return false; }
PyObject *exe_dir = PyUnicode_DecodeFSDefaultAndSize(run_data->exe_dir, strlen(run_data->exe_dir));
if (exe_dir == NULL) { fprintf(stderr, "Fatal error: cannot decode exe_dir: %s\n", run_data->exe_dir); PyErr_Print(); return false; }
#define S(key, val) { if (!val) { PyErr_Print(); return false; } int ret = PyDict_SetItemString(ans, #key, val); Py_CLEAR(val); if (ret != 0) { PyErr_Print(); return false; } }
if (exe_dir == NULL) { fprintf(stderr, "Fatal error: cannot decode exe_dir: %s\n", run_data->exe_dir); PyErr_Print(); Py_CLEAR(ans); return false; }
#define S(key, val) { if (!val) { PyErr_Print(); Py_CLEAR(ans); return false; } int ret = PyDict_SetItemString(ans, #key, val); Py_CLEAR(val); if (ret != 0) { PyErr_Print(); Py_CLEAR(ans); return false; } }
S(bundle_exe_dir, exe_dir);
if (from_source) {
PyObject *one = Py_True; Py_INCREF(one);