aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Miroshnychenko <roman.miroshnychenko@comeet.co>2020-06-16 12:53:07 +0300
committerRoman Miroshnychenko <roman.miroshnychenko@comeet.co>2020-06-16 16:05:53 +0300
commit133b9564733eea6d24d07ccd1874d882d5f9ba9e (patch)
tree7667c53e8b80f599f18ea81970d696c5d4bfe685
parent750633b22ed19a67bc92184fefc5b79a1a1f2a22 (diff)
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}))