summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-04-08 22:23:05 +0200
committerGitHub <noreply@github.com>2021-04-08 22:23:05 +0200
commitdfac2e2d25c18e96a437561e6528b92a82887b32 (patch)
treea57828e5ebea6a2bef6923f342754d3740e5c9eb /src/core
parentMerge pull request #6154 from lioncash/svcrange2 (diff)
parentnvhost_nvdec_common: Avoid memcpy with null pointers (diff)
downloadyuzu-dfac2e2d25c18e96a437561e6528b92a82887b32.tar
yuzu-dfac2e2d25c18e96a437561e6528b92a82887b32.tar.gz
yuzu-dfac2e2d25c18e96a437561e6528b92a82887b32.tar.bz2
yuzu-dfac2e2d25c18e96a437561e6528b92a82887b32.tar.lz
yuzu-dfac2e2d25c18e96a437561e6528b92a82887b32.tar.xz
yuzu-dfac2e2d25c18e96a437561e6528b92a82887b32.tar.zst
yuzu-dfac2e2d25c18e96a437561e6528b92a82887b32.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp17
1 files changed, 11 insertions, 6 deletions
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