Commit 3b1e9e86 authored by Richard Gobeille's avatar Richard Gobeille
Browse files

engine: bail out of voxcache_fetchvoxmodel() if the offsets found in...

engine: bail out of voxcache_fetchvoxmodel() if the offsets found in texturecache.index don't lead to the expected data
parent d6813b15
......@@ -925,7 +925,13 @@ voxmodel_t* voxcache_fetchvoxmodel(const char* const cacheid)
voxmodel_t* vm = (voxmodel_t*)Xcalloc(1, sizeof(voxmodel_t));
texcache.dataFilePos = texcache.entries[i]->offset;
texcache_readdata(&voxd, sizeof(voxd));
if (texcache_readdata(&voxd, sizeof(voxd)) || voxd.compressed_size <= 0)
{
Xfree(vm);
return NULL;
}
vm->mytexx = voxd.mytexx;
vm->mytexy = voxd.mytexy;
vm->qcnt = voxd.qcnt;
......@@ -938,9 +944,15 @@ voxmodel_t* voxcache_fetchvoxmodel(const char* const cacheid)
auto bytes = LZ4_decompress_safe(compressed_data, decompressed_data, voxd.compressed_size, totalsize);
Xfree(compressed_data);
UNREFERENCED_PARAMETER(bytes);
Bassert(bytes > 0);
if (bytes <= 0)
{
Xfree(decompressed_data);
Xfree(vm);
return NULL;
}
vm->vertex = (GLfloat*)Xmalloc(vertexsize);
Bmemcpy(vm->vertex, decompressed_data, vertexsize);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment