diff options
author | Campbell Barton <campbell@blender.org> | 2022-04-07 08:43:23 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-04-07 08:45:20 +0300 |
commit | e2f4c4db8d6cbe4694c24d599e16ee3889871bdd (patch) | |
tree | a3be9aecfcac72e0ddaf45471b56a29900101ebf /source/blender/python | |
parent | f49a736ff4023231483c7e535ca2a7f2869d641d (diff) |
Cleanup: pass the buffer length into `txt_insert_buf`
Also remove redundant NULL check.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_rna_text.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_rna_text.c b/source/blender/python/intern/bpy_rna_text.c index 44568ad30a6..fedb914256a 100644 --- a/source/blender/python/intern/bpy_rna_text.c +++ b/source/blender/python/intern/bpy_rna_text.c @@ -6,6 +6,8 @@ * This file extends the text editor with C/Python API methods and attributes. */ +#define PY_SSIZE_T_CLEAN + #include <Python.h> #include "DNA_text_types.h" @@ -103,9 +105,16 @@ static PyObject *bpy_rna_region_from_string(PyObject *self, PyObject *args) /* Parse the region range. */ const char *buf; + Py_ssize_t buf_len; TextRegion region; - if (!PyArg_ParseTuple( - args, "s|((ii)(ii))", &buf, ®ion.curl, ®ion.curc, ®ion.sell, ®ion.selc)) { + if (!PyArg_ParseTuple(args, + "s#|((ii)(ii))", + &buf, + &buf_len, + ®ion.curl, + ®ion.curc, + ®ion.sell, + ®ion.selc)) { return NULL; } @@ -114,7 +123,7 @@ static PyObject *bpy_rna_region_from_string(PyObject *self, PyObject *args) } /* Set the selected text. */ - txt_insert_buf(text, buf); + txt_insert_buf(text, buf, buf_len); /* Update the text editor. */ WM_main_add_notifier(NC_TEXT | NA_EDITED, text); |