From 06b414377481033beaba3e026837d2a7c0b75068 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sat, 11 Jan 2020 00:45:11 +0100 Subject: [PATCH] Fix deserialization of submap radiation: (#36903) Check bounds before setting the value. --- src/savegame_json.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 7627e6969cfb2..af95a104f5d1c 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -3806,10 +3806,10 @@ void submap::load( JsonIn &jsin, const std::string &member_name, int version ) int rad_strength = jsin.get_int(); int rad_num = jsin.get_int(); for( int i = 0; i < rad_num; ++i ) { - // A little array trick here, assign to it as a 1D array. - // If it's not in bounds we're kinda hosed anyway. - set_radiation( { 0, rad_cell }, rad_strength ); - rad_cell++; + if( rad_cell < SEEX * SEEY ) { + set_radiation( { 0 % SEEX, rad_cell / SEEX }, rad_strength ); + rad_cell++; + } } } } else if( member_name == "furniture" ) {