From e4afa06dab143adca4fa6a955ccabb9a4d9729d2 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Mon, 24 Apr 2023 11:48:22 +0200 Subject: [PATCH] Fix #107261: bpy.types.Text (region_as_string/region_from_string) crash These two didnt check if keywords were passed in, crashed on running `PyDict_GET_SIZE` on NULL (in case of no keywords). Oversight in ee292a1d66b2. Now just check if keywords are actually passed in. Pull Request: https://projects.blender.org/blender/blender/pulls/107285 --- source/blender/python/intern/bpy_rna_text.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/python/intern/bpy_rna_text.c b/source/blender/python/intern/bpy_rna_text.c index 7ccc70cc7fa..9653ecbe1e3 100644 --- a/source/blender/python/intern/bpy_rna_text.c +++ b/source/blender/python/intern/bpy_rna_text.c @@ -75,7 +75,7 @@ static PyObject *bpy_rna_region_as_string(PyObject *self, PyObject *args, PyObje return NULL; } - if (PyDict_GET_SIZE(kwds) > 0) { + if (kwds && PyDict_GET_SIZE(kwds) > 0) { txt_sel_set(text, region.curl, region.curc, region.sell, region.selc); } @@ -140,7 +140,7 @@ static PyObject *bpy_rna_region_from_string(PyObject *self, PyObject *args, PyOb return NULL; } - if (PyDict_GET_SIZE(kwds) > 0) { + if (kwds && PyDict_GET_SIZE(kwds) > 0) { txt_sel_set(text, region.curl, region.curc, region.sell, region.selc); }