summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 {
23template <typename T> 23template <typename T>
24std::size_t SpliceVectors(const std::vector<u8>& input, std::vector<T>& dst, std::size_t count, 24std::size_t SpliceVectors(const std::vector<u8>& input, std::vector<T>& dst, std::size_t count,
25 std::size_t offset) { 25 std::size_t offset) {
26 std::memcpy(dst.data(), input.data() + offset, count * sizeof(T)); 26 if (!dst.empty()) {
27 offset += count * sizeof(T); 27 std::memcpy(dst.data(), input.data() + offset, count * sizeof(T));
28 return offset; 28 }
29 return 0;
29} 30}
30 31
31// Write vectors will write data to the output buffer 32// Write vectors will write data to the output buffer
32template <typename T> 33template <typename T>
33std::size_t WriteVectors(std::vector<u8>& dst, const std::vector<T>& src, std::size_t offset) { 34std::size_t WriteVectors(std::vector<u8>& dst, const std::vector<T>& src, std::size_t offset) {
34 std::memcpy(dst.data() + offset, src.data(), src.size() * sizeof(T)); 35 if (src.empty()) {
35 offset += src.size() * sizeof(T); 36 return 0;
36 return offset; 37 } else {
38 std::memcpy(dst.data() + offset, src.data(), src.size() * sizeof(T));
39 offset += src.size() * sizeof(T);
40 return offset;
41 }
37} 42}
38} // Anonymous namespace 43} // Anonymous namespace
39 44