yuzu-emu
/
yuzu
Archived
1
0
Fork 0

nvhost_ctrl_gpu: Avoid sending null pointer to memcpy

Undefined Behaviour Sanitizer reports a null pointer is being sent to
memcpy, thought it's "guaranteed to never be null". Guard it with an if
statement, and log when the action has been averted.
This commit is contained in:
lat9nq 2021-04-04 15:39:38 -04:00
parent 69b2dbdffd
commit 638c892edf
1 changed files with 7 additions and 1 deletions

View File

@ -248,7 +248,13 @@ NvResult nvhost_ctrl_gpu::ZBCSetTable(const std::vector<u8>& input, std::vector<
IoctlZbcSetTable params{};
std::memcpy(&params, input.data(), input.size());
// TODO(ogniK): What does this even actually do?
// Prevent null pointer being passed as arg 1
if (output.empty()) {
LOG_WARNING(Service_NVDRV, "Avoiding passing null pointer to memcpy");
} else {
std::memcpy(output.data(), &params, output.size());
}
return NvResult::Success;
}