forked from ShuriZma/suyu
1
0
Fork 0

gl_shader_disk_cache: Check LZ4 size limit

Co-Authored-By: ReinUsesLisp <reinuseslisp@airmail.cc>
This commit is contained in:
Frederic L 2019-02-03 01:22:01 -03:00 committed by ReinUsesLisp
parent 9f0b247cf6
commit d0ac624403
1 changed files with 4 additions and 0 deletions

View File

@ -53,6 +53,10 @@ ShaderCacheVersionHash GetShaderCacheVersionHash() {
template <typename T>
std::vector<u8> CompressData(const T* source, std::size_t source_size) {
if (source_size > LZ4_MAX_INPUT_SIZE) {
// Source size exceeds LZ4 maximum input size
return {};
}
const auto source_size_int = static_cast<int>(source_size);
const int max_compressed_size = LZ4_compressBound(source_size_int);
std::vector<u8> compressed(max_compressed_size);