From 2b8f8c826d787fb1fc1c2835efb95ff854d75194 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 8 Jan 2023 14:36:52 -0700 Subject: [PATCH] light: Mod_Q1BSP_DecompressVis: port safety check from DecompressRow --- light/ltface.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/light/ltface.cc b/light/ltface.cc index 0371903f..6dbc1720 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -465,7 +465,13 @@ static void Mod_Q1BSP_DecompressVis(const uint8_t *in, const uint8_t *inend, uin return; } - for (c = *in++; c > 0; c--) { + const int run_length = *in++; + if (!run_length) { + logging::print("Mod_Q1BSP_DecompressVis: 0 repeat\n"); + return; + } + + for (c = run_length; c > 0; c--) { if (out == outend) { logging::print("Mod_Q1BSP_DecompressVis: output overrun (decompressed {} of {} output bytes)\n", (out - outstart), (outend - outstart));