From 37acb0cae894395f0714940d034a3382bc8c62af Mon Sep 17 00:00:00 2001 From: Campbell Barton <campbell@blender.org> Date: Fri, 15 Sep 2023 12:23:42 +1000 Subject: [PATCH] Fix #112399: Memory leak with exceptions from scripts in the text editor Regression in [0] caused the function to jump to the error in the text editor not to restore the exception, using the trace-back being iterated over instead of the original value. [0]: 2d2baeaf04d481f284bc2f098fb6d7ee9268151f Pull Request: https://projects.blender.org/blender/blender/pulls/112708 --- source/blender/python/intern/bpy_traceback.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c index 1466d674384..f36a89a96e4 100644 --- a/source/blender/python/intern/bpy_traceback.c +++ b/source/blender/python/intern/bpy_traceback.c @@ -216,12 +216,12 @@ bool python_script_error_jump( else { PyErr_NormalizeException(&exception, &value, (PyObject **)&tb); - for (tb = (PyTracebackObject *)PySys_GetObject("last_traceback"); - tb && (PyObject *)tb != Py_None; - tb = tb->tb_next) + for (PyTracebackObject *tb_iter = (PyTracebackObject *)PySys_GetObject("last_traceback"); + tb_iter && (PyObject *)tb_iter != Py_None; + tb_iter = tb_iter->tb_next) { PyObject *coerce; - const char *tb_filepath = traceback_filepath(tb, &coerce); + const char *tb_filepath = traceback_filepath(tb_iter, &coerce); const int match = ((BLI_path_cmp(tb_filepath, filepath) == 0) || (ELEM(tb_filepath[0], '\\', '/') && BLI_path_cmp(tb_filepath + 1, filepath) == 0)); @@ -229,7 +229,7 @@ bool python_script_error_jump( if (match) { success = true; - *r_lineno = *r_lineno_end = tb->tb_lineno; + *r_lineno = *r_lineno_end = tb_iter->tb_lineno; /* used to break here, but better find the inner most line */ } } -- GitLab