Skip to content

Commit

Permalink
fix off-by-1 crash bug in sidebar as per electronicarts#105
Browse files Browse the repository at this point in the history
  • Loading branch information
ChthonVII committed Jun 23, 2021
1 parent df34288 commit 9ff76b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions REDALERT/SIDEBAR.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,8 @@ void SidebarClass::StripClass::Deactivate(void)
*=============================================================================================*/
bool SidebarClass::StripClass::Add(RTTIType type, int id, bool via_capture)
{
if (BuildableCount <= MAX_BUILDABLES) {
// Chthon CFE Note: bugfix as per https://github.com/electronicarts/CnC_Remastered_Collection/issues/105
if (BuildableCount < MAX_BUILDABLES) {
for (int index = 0; index < BuildableCount; index++) {
if (Buildables[index].BuildableType == type && Buildables[index].BuildableID == id) {
return(false);
Expand Down Expand Up @@ -2475,4 +2476,4 @@ void SidebarClass::Zoom_Mode_Control(void)
}
}
#endif
}
}
5 changes: 3 additions & 2 deletions REDALERT/SIDEBARGlyphx.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ void SidebarGlyphxClass::StripClass::Init_Clear(void)
*=============================================================================================*/
bool SidebarGlyphxClass::StripClass::Add(RTTIType type, int id, bool via_capture)
{
if (BuildableCount <= MAX_BUILDABLES) {
// Chthon CFE Note: bugfix as per https://github.com/electronicarts/CnC_Remastered_Collection/issues/105
if (BuildableCount < MAX_BUILDABLES) {
for (int index = 0; index < BuildableCount; index++) {
if (Buildables[index].BuildableType == type && Buildables[index].BuildableID == id) {
return(false);
Expand Down Expand Up @@ -818,4 +819,4 @@ void Sidebar_Glyphx_Decode_Pointers(SidebarGlyphxClass *sidebar)
if (sidebar) {
sidebar->Decode_Pointers();
}
}
}
3 changes: 2 additions & 1 deletion TIBERIANDAWN/SIDEBAR.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,8 @@ static int sortfunc(void const * ptr1, void const * ptr2)
*=============================================================================================*/
bool SidebarClass::StripClass::Add(RTTIType type, int id, bool via_capture)
{
if (BuildableCount <= MAX_BUILDABLES) {
// Chthon CFE Note: bugfix as per https://github.com/electronicarts/CnC_Remastered_Collection/issues/105
if (BuildableCount < MAX_BUILDABLES) {
for (int index = 0; index < BuildableCount; index++) {
if (Buildables[index].BuildableType == type && Buildables[index].BuildableID == id) {
return(false);
Expand Down
5 changes: 3 additions & 2 deletions TIBERIANDAWN/SIDEBARGlyphx.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ void SidebarGlyphxClass::StripClass::Init_Clear(void)
*=============================================================================================*/
bool SidebarGlyphxClass::StripClass::Add(RTTIType type, int id, bool via_capture)
{
if (BuildableCount <= MAX_BUILDABLES) {
// Chthon CFE Note: bugfix as per https://github.com/electronicarts/CnC_Remastered_Collection/issues/105
if (BuildableCount < MAX_BUILDABLES) {
for (int index = 0; index < BuildableCount; index++) {
if (Buildables[index].BuildableType == type && Buildables[index].BuildableID == id) {
return(false);
Expand Down Expand Up @@ -830,4 +831,4 @@ void Sidebar_Glyphx_Decode_Pointers(SidebarGlyphxClass *sidebar)
sidebar->Decode_Pointers();
}
}


0 comments on commit 9ff76b8

Please sign in to comment.