d3d12: Fix uninitialized variable referenced in error case

Clang warns that errorString is uninitialized if printBlobUtf8
is null, meaning GetBlobAsUtf8 failed, but then we go ahead and
access it (and printBlobUtf8) after the if. Expand the if to
encompass the printing.

Fixes: 2ea15cd6 ("d3d12: introduce d3d12 gallium driver")

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8248>
This commit is contained in:
Jesse Natalie 2020-12-28 10:52:44 -08:00 committed by Marge Bot
parent 9252f947e5
commit ca5df4273e
1 changed files with 5 additions and 5 deletions

View File

@ -1269,12 +1269,12 @@ bool d3d12_validation_tools::validate_and_sign(struct blob *dxil)
char *errorString;
if (printBlobUtf8) {
errorString = reinterpret_cast<char*>(printBlobUtf8->GetBufferPointer());
}
errorString[printBlobUtf8->GetBufferSize() - 1] = 0;
debug_printf("== VALIDATION ERROR =============================================\n%s\n"
"== END ==========================================================\n",
errorString);
errorString[printBlobUtf8->GetBufferSize() - 1] = 0;
debug_printf("== VALIDATION ERROR =============================================\n%s\n"
"== END ==========================================================\n",
errorString);
}
return false;
}