Skip to content

Commit

Permalink
Fix overflow in CollectTheCast and add an error check
Browse files Browse the repository at this point in the history
  • Loading branch information
pbdot committed Jan 30, 2025
1 parent e928474 commit 7a9dfff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
9 changes: 2 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,15 @@ if (EDGE_SOKOL_GL OR EDGE_SOKOL_GLES3 OR EDGE_SOKOL_D3D11)
set (EDGE_SOKOL ON)
endif()

# memory allocator
option(EDGE_MIMALLOC "Enable mimalloc" ON)
if (${CMAKE_SIZEOF_VOID_P} MATCHES 4)
set(EDGE_MIMALLOC OFF)
message(STATUS "Forcing mimalloc off for 32 bit build")
endif()

# Optional Features
option(EDGE_CLASSIC "Enable default features for EDGE-Classic" ON)

# Development
option(EDGE_SANITIZE "Enable code sanitizing" OFF)
option(EDGE_PROFILING "Enable Profiling" OFF)

# memory allocator
option(EDGE_MIMALLOC "Enable mimalloc" ON)
# Enables exhaustive memory checks, see mimalloc CMakeLists.txt for what is enabled
# Memory error logging goes to debug.txt
option(EDGE_MEMORY_CHECK "Enable Memory Checks" OFF)
Expand Down
7 changes: 6 additions & 1 deletion source_files/dehacked/deh_things.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static constexpr char kExtraFlagNoRaise = 'R';
static constexpr char kExtraFlagNoGrudge = 'G';
static constexpr char kExtraFlagNoItemBk = 'I';

static constexpr uint8_t kCastMaximum = 17;
static constexpr uint8_t kCastMaximum = 18;

extern DehackedMapObjectDefinition mobjinfo[kTotalDehackedMapObjectTypesPortCompatibility];

Expand Down Expand Up @@ -1149,6 +1149,11 @@ void CollectTheCast()
continue;
}

if (order >= kCastMaximum)
{
FatalError("CollectTheCast() - Overflow");
}

cast_mobjs[order] = mt_num;
}
}
Expand Down

0 comments on commit 7a9dfff

Please sign in to comment.