Rework _Py_DumpASCII() to make Coverity happy

This commit is contained in:
Victor Stinner 2016-03-23 16:10:07 +01:00
parent 928ad285b5
commit 1c3069aed6
1 changed files with 8 additions and 8 deletions

View File

@ -545,23 +545,23 @@ _Py_DumpASCII(int fd, PyObject *text)
size = ascii->length;
kind = ascii->state.kind;
if (ascii->state.compact) {
if (kind == PyUnicode_WCHAR_KIND) {
wstr = ((PyASCIIObject *)text)->wstr;
if (wstr == NULL)
return;
size = ((PyCompactUnicodeObject *)text)->wstr_length;
}
else if (ascii->state.compact) {
if (ascii->state.ascii)
data = ((PyASCIIObject*)text) + 1;
else
data = ((PyCompactUnicodeObject*)text) + 1;
}
else if (kind != PyUnicode_WCHAR_KIND) {
else {
data = ((PyUnicodeObject *)text)->data.any;
if (data == NULL)
return;
}
else {
wstr = ((PyASCIIObject *)text)->wstr;
if (wstr == NULL)
return;
size = ((PyCompactUnicodeObject *)text)->wstr_length;
}
if (MAX_STRING_LENGTH < size) {
size = MAX_STRING_LENGTH;