nvhost_nvdec_common: Avoid memcpy with null pointers
Avoid sending null pointer to memcpy as reported by Undefined Behavious Sanitizer. Co-authored-by: LC <mathew1800@gmail.com>
This commit is contained in:
parent
69b2dbdffd
commit
2cc42e40c5
|
@ -23,17 +23,22 @@ namespace {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::size_t SpliceVectors(const std::vector<u8>& input, std::vector<T>& dst, std::size_t count,
|
std::size_t SpliceVectors(const std::vector<u8>& input, std::vector<T>& dst, std::size_t count,
|
||||||
std::size_t offset) {
|
std::size_t offset) {
|
||||||
std::memcpy(dst.data(), input.data() + offset, count * sizeof(T));
|
if (!dst.empty()) {
|
||||||
offset += count * sizeof(T);
|
std::memcpy(dst.data(), input.data() + offset, count * sizeof(T));
|
||||||
return offset;
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write vectors will write data to the output buffer
|
// Write vectors will write data to the output buffer
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::size_t WriteVectors(std::vector<u8>& dst, const std::vector<T>& src, std::size_t offset) {
|
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));
|
if (src.empty()) {
|
||||||
offset += src.size() * sizeof(T);
|
return 0;
|
||||||
return offset;
|
} else {
|
||||||
|
std::memcpy(dst.data() + offset, src.data(), src.size() * sizeof(T));
|
||||||
|
offset += src.size() * sizeof(T);
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
|
|
Reference in New Issue