Browse Source

dcparser: Improve assertion error message for invalid UTF-8 data

rdb 4 years ago
parent
commit
ca061c98a6
1 changed files with 4 additions and 0 deletions
  1. 4 0
      direct/src/dcparser/dcPacker.cxx

+ 4 - 0
direct/src/dcparser/dcPacker.cxx

@@ -889,6 +889,10 @@ unpack_object() {
       unpack_string(str);
 #if PY_MAJOR_VERSION >= 3
       object = PyUnicode_FromStringAndSize(str.data(), str.size());
+      if (object == nullptr) {
+        nassert_raise("Unable to decode UTF-8 string; use blob type for binary data");
+        return nullptr;
+      }
 #else
       object = PyString_FromStringAndSize(str.data(), str.size());
 #endif