summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar lat9nq2021-04-04 15:39:38 -0400
committerGravatar lat9nq2021-04-05 00:49:09 -0400
commit638c892edf806837702f80ad5a0e57da0c8dbabe (patch)
tree9f078a2483f31b6a3744834b31a83b75346c35d8
parentMerge pull request #6139 from Morph1984/cmake-fix-build (diff)
downloadyuzu-638c892edf806837702f80ad5a0e57da0c8dbabe.tar.gz
yuzu-638c892edf806837702f80ad5a0e57da0c8dbabe.tar.xz
yuzu-638c892edf806837702f80ad5a0e57da0c8dbabe.zip
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.
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
index 933d42f3f..2edd803f3 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
@@ -248,7 +248,13 @@ NvResult nvhost_ctrl_gpu::ZBCSetTable(const std::vector<u8>& input, std::vector<
248 IoctlZbcSetTable params{}; 248 IoctlZbcSetTable params{};
249 std::memcpy(&params, input.data(), input.size()); 249 std::memcpy(&params, input.data(), input.size());
250 // TODO(ogniK): What does this even actually do? 250 // TODO(ogniK): What does this even actually do?
251 std::memcpy(output.data(), &params, output.size()); 251
252 // Prevent null pointer being passed as arg 1
253 if (output.empty()) {
254 LOG_WARNING(Service_NVDRV, "Avoiding passing null pointer to memcpy");
255 } else {
256 std::memcpy(output.data(), &params, output.size());
257 }
252 return NvResult::Success; 258 return NvResult::Success;
253} 259}
254 260