aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Blake <oak99sky@yahoo.co.uk>2020-07-15 10:37:13 +0100
committerGitHub <noreply@github.com>2020-07-15 10:37:13 +0100
commitc23b69d150637747de6432410d4c5f1df69a3252 (patch)
tree13b55505792d54bbb060dba06b4a74c44bd36402
parent0311ee3049cdcfdb1f1fdee3b214b6c184feda16 (diff)
parent133b9564733eea6d24d07ccd1874d882d5f9ba9e (diff)
Merge pull request #18067 from romanvm/fix_python_buffer_size
[Python] Fix allocating buffer for a Python unicode string
-rw-r--r--xbmc/interfaces/python/typemaps/python.buffer.intm7
1 files changed, 4 insertions, 3 deletions
diff --git a/xbmc/interfaces/python/typemaps/python.buffer.intm b/xbmc/interfaces/python/typemaps/python.buffer.intm
index 76c09cb783..57f350d81f 100644
--- a/xbmc/interfaces/python/typemaps/python.buffer.intm
+++ b/xbmc/interfaces/python/typemaps/python.buffer.intm
@@ -9,10 +9,11 @@
%>
if (PyUnicode_Check(${slarg}))
{
- const char* str = PyUnicode_AsUTF8(${slarg});
- size_t size = (size_t)PyUnicode_GetLength(${slarg});
+ Py_ssize_t pysize;
+ const char* str = PyUnicode_AsUTF8AndSize(${slarg}, &pysize);
+ size_t size = static_cast<size_t>(pysize);
${api}.allocate(size);
- ${api}.put(str,size);
+ ${api}.put(str, size);
${api}.flip(); // prepare the buffer for reading from
}
else if (PyByteArray_Check(${slarg}))