From b1ac8004e7cd16470354dcd2c318366954503128 Mon Sep 17 00:00:00 2001 From: bhuvan-somisetty Date: Mon, 5 Oct 2026 15:02:53 +0530 Subject: [PATCH] py_loader: release PyObject_Str results in error print and error value py_loader_impl_error_print never released type_str_obj and value_str_obj, and py_loader_impl_error_value_from_exception never released value_str_obj. Both come from PyObject_Str so they are new references, and they leaked every time a python error was handled. exception_create_const copies the strings, so it is safe to release them after creating the exception. Found with valgrind. --- source/loaders/py_loader/source/py_loader_impl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/loaders/py_loader/source/py_loader_impl.c b/source/loaders/py_loader/source/py_loader_impl.c index 34da197c9..1d9c12bef 100644 --- a/source/loaders/py_loader/source/py_loader_impl.c +++ b/source/loaders/py_loader/source/py_loader_impl.c @@ -3926,6 +3926,8 @@ void py_loader_impl_error_print(loader_impl_py py_impl) log_write("metacall", LOG_LEVEL_ERROR, error_format_str, type_str, value_str, traceback_str ? traceback_str : traceback_not_found); + Py_DecRef(type_str_obj); + Py_DecRef(value_str_obj); Py_DecRef(traceback_list); Py_DecRef(separator); Py_DecRef(traceback_str_obj); @@ -3982,6 +3984,7 @@ value py_loader_impl_error_value_from_exception(loader_impl_py py_impl, PyObject ret = value_create_throwable(th); + Py_DecRef(value_str_obj); Py_DecRef(traceback_list); Py_DecRef(separator); Py_DecRef(traceback_str_obj);