From cebab8f85d7f5366568b6d52f61fce2aac7e8659 Mon Sep 17 00:00:00 2001 From: Johan Mattsson <39247600+mjunix@users.noreply.github.com> Date: Sun, 2 Apr 2023 14:10:57 +0200 Subject: [PATCH] Small fixes (#910) * Fix potential index out of bounds * Fix potential index out of bounds * Use 'MAXGEOSECTORS' instead of magic constant --- source/games/duke/src/d_menu.cpp | 2 +- source/games/duke/src/premap_r.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index 24083a0c9..57b1433b6 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -101,7 +101,7 @@ bool GameInterface::StartGame(FNewGameStartup& gs) static const uint16_t sounds_d[] = { JIBBED_ACTOR6, BONUS_SPEECH1, DUKE_GETWEAPON2, JIBBED_ACTOR5, JIBBED_ACTOR5 }; static const uint16_t sounds_r[] = { 427, 428, 196, 195, 197 }; - if (gs.Skill >=0 && gs.Skill <= 5) skillsound = isRR()? sounds_r[gs.Skill] : sounds_d[gs.Skill]; + if (gs.Skill >=0 && gs.Skill < 5) skillsound = isRR()? sounds_r[gs.Skill] : sounds_d[gs.Skill]; if (menu_sounds && skillsound >= 0 && SoundEnabled() && !netgame) { diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index fd1d42d2d..d815ad83e 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -528,7 +528,7 @@ void prelevel_r(int g, TArray& actors) if (!actor->exists()) continue; if (actor->GetClass()->TypeName == NAME_RedneckGeometryEffect) { - if (geocnt > 64) + if (geocnt >= MAXGEOSECTORS) I_Error("Too many geometry effects"); if (actor->spr.hitag == 0) {