aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.araujo@kdab.com>2019-07-31 16:34:28 -0300
committerRenato Araujo Oliveira Filho <renato.araujo@kdab.com>2019-08-07 16:34:47 -0300
commitefc7ad5498ff03de8a444a8c1d880f949aaf4d43 (patch)
treed5ee27861fcd65786aa813b06ae0dce8d642e7cf /sources/shiboken2/generator/shiboken2/cppgenerator.cpp
parent68b2245519570314a983baa7cda850ace13f7f81 (diff)
Fix crash when accessing a invalid property in the smart pointer
Sbk_*_getattro receives an utf8 string and we need to convert it to ascii string before use it on PyErr_Format. Change-Id: Ie3cf5286c9eb6b01f86347b00d523837ca41de32 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/generator/shiboken2/cppgenerator.cpp')
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index e36b6edc3..68bcfe508 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -5387,7 +5387,7 @@ void CppGenerator::writeGetattroFunction(QTextStream &s, GeneratorContext &conte
s << INDENT << "PyTypeObject *tp = Py_TYPE(self);" << endl;
s << INDENT << "PyErr_Format(PyExc_AttributeError," << endl;
s << INDENT << " \"'%.50s' object has no attribute '%.400s'\"," << endl;
- s << INDENT << " tp->tp_name, PyBytes_AS_STRING(name));" << endl;
+ s << INDENT << " tp->tp_name, Shiboken::String::toCString(name));" << endl;
s << INDENT << "return nullptr;" << endl;
}
s << INDENT << "} else {" << endl;