Fix seg fault using Python 2 invalid utf-8 strings and wstring
Fixes seg fault when passing a Python string, containing invalid utf-8 content, to a wstring or wchar * parameter. A TypeError is thrown instead, eg: %include <std_wstring.i> void instring(const std::wstring& s); instring(b"h\xe9llooo") # Python
This commit is contained in:
parent
3915e7bd08
commit
e96316bf31
5 changed files with 57 additions and 4 deletions
|
|
@ -94,6 +94,14 @@ void test_throw() TESTCASE_THROW1(std::wstring){
|
|||
throw x;
|
||||
}
|
||||
|
||||
const char * non_utf8_c_str() {
|
||||
return "h\xe9llo";
|
||||
}
|
||||
|
||||
size_t size_wstring(const std::wstring& s) {
|
||||
return s.size();
|
||||
}
|
||||
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue