diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp | 8 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp | 17 |
2 files changed, 18 insertions, 7 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< IoctlZbcSetTable params{}; std::memcpy(¶ms, input.data(), input.size()); // TODO(ogniK): What does this even actually do? - std::memcpy(output.data(), ¶ms, output.size()); + + // 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(), ¶ms, output.size()); + } return NvResult::Success; } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp index 4898dc27a..c2f152190 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp @@ -23,17 +23,22 @@ namespace { template <typename T> std::size_t SpliceVectors(const std::vector<u8>& input, std::vector<T>& dst, std::size_t count, std::size_t offset) { - std::memcpy(dst.data(), input.data() + offset, count * sizeof(T)); - offset += count * sizeof(T); - return offset; + if (!dst.empty()) { + std::memcpy(dst.data(), input.data() + offset, count * sizeof(T)); + } + return 0; } // Write vectors will write data to the output buffer template <typename T> std::size_t WriteVectors(std::vector<u8>& dst, const std::vector<T>& src, std::size_t offset) { - std::memcpy(dst.data() + offset, src.data(), src.size() * sizeof(T)); - offset += src.size() * sizeof(T); - return offset; + if (src.empty()) { + return 0; + } else { + std::memcpy(dst.data() + offset, src.data(), src.size() * sizeof(T)); + offset += src.size() * sizeof(T); + return offset; + } } } // Anonymous namespace |