diff --git a/common/wspudp.cpp b/common/wspudp.cpp index 3c3da6af..4b38b34a 100644 --- a/common/wspudp.cpp +++ b/common/wspudp.cpp @@ -94,12 +94,12 @@ UDPInterfaceClass::UDPInterfaceClass(void) UDPInterfaceClass::~UDPInterfaceClass(void) { while (BroadcastAddresses.Count()) { - delete BroadcastAddresses[0]; + delete[] BroadcastAddresses[0]; BroadcastAddresses.Delete(0); } while (LocalAddresses.Count()) { - delete LocalAddresses[0]; + delete[] LocalAddresses[0]; LocalAddresses.Delete(0); } diff --git a/redalert/bdata.cpp b/redalert/bdata.cpp index 382a1fcc..d10efdf2 100644 --- a/redalert/bdata.cpp +++ b/redalert/bdata.cpp @@ -3354,7 +3354,7 @@ short const* BuildingTypeClass::Occupy_List(bool placement) const if (placement && Bib_And_Offset(bib, cell)) { SmudgeTypeClass const& smudge = SmudgeTypeClass::As_Reference(bib); - static short _list[25]; + static short _list[50]; short* dest = &_list[0]; /* diff --git a/redalert/display.cpp b/redalert/display.cpp index a7766838..b40bc17e 100644 --- a/redalert/display.cpp +++ b/redalert/display.cpp @@ -624,8 +624,12 @@ void DisplayClass::Set_Cursor_Shape(short const* list) if (list) { int w, h; static short _list[50]; + const short* src = list; + short* dst = _list; + + while ((*dst++ = *src++) != REFRESH_EOL) + ; /* Copy is done in condition. */ - memcpy(_list, list, sizeof(_list)); CursorSize = _list; Get_Occupy_Dimensions(w, h, CursorSize); ZoneOffset = -(((h / 2) * MAP_CELL_W) + (w / 2)); diff --git a/redalert/loaddlg.cpp b/redalert/loaddlg.cpp index d3f70044..f4880309 100644 --- a/redalert/loaddlg.cpp +++ b/redalert/loaddlg.cpp @@ -544,7 +544,12 @@ int LoadOptionsClass::Process(void) if (game_descr[0] == '(') { char* ptr = strchr(game_descr, ')'); if (ptr != NULL) { - strcpy(game_descr, ptr + 1); + char* dst = game_descr; + const char* src = ptr + 1; // Skip ')' + + // Don't use strcpy, as the memory regions overlap. + while ((*dst++ = *src++) != '\0') + ; // Copy string strtrim(game_descr); } } diff --git a/redalert/sounddlg.cpp b/redalert/sounddlg.cpp index 55aaf130..8daf6508 100644 --- a/redalert/sounddlg.cpp +++ b/redalert/sounddlg.cpp @@ -433,7 +433,7 @@ void SoundControlsClass::Process(void) while (listbox.Count()) { char const* ptr = listbox.Get_Item(0); listbox.Remove_Item(ptr); - delete[](void*) ptr; + delete[] ptr; } } diff --git a/redalert/statbtn.cpp b/redalert/statbtn.cpp index 2f82f713..a91a2f12 100644 --- a/redalert/statbtn.cpp +++ b/redalert/statbtn.cpp @@ -261,3 +261,20 @@ void StaticButtonClass::Draw_Text(char const* text) Fancy_Text_Print(text, x, Y, GadgetClass::Get_Color_Scheme(), TBLACK, PrintFlags); } } + +/*********************************************************************************************** + * StaticButtonClass::~StaticButtonClass -- Destructor of StaticButtonClass. * + * * + * INPUT: none * + * * + * OUTPUT: none * + * * + * WARNINGS: none * + * * + * HISTORY: * + * 12/09/2021 mrparrot : Created * + *=============================================================================================*/ +StaticButtonClass::~StaticButtonClass(void) +{ + delete[] String; +} diff --git a/redalert/statbtn.h b/redalert/statbtn.h index 30fb3231..d2906a77 100644 --- a/redalert/statbtn.h +++ b/redalert/statbtn.h @@ -43,6 +43,7 @@ class StaticButtonClass : public GadgetClass public: StaticButtonClass(void); StaticButtonClass(unsigned id, char const* text, TextPrintType style, int x, int y, int w = -1, int h = -1); + ~StaticButtonClass(void); virtual int Draw_Me(int forced = false); virtual void Set_Text(char const* text, bool resize = false); diff --git a/redalert/techno.cpp b/redalert/techno.cpp index a8fc6bbc..45efbef1 100644 --- a/redalert/techno.cpp +++ b/redalert/techno.cpp @@ -5341,7 +5341,8 @@ bool TechnoClass::Evaluate_Object(ThreatType method, ** Never recruit sticky guard units to defend a base. */ if (!infantry->Is_Weapon_Equipped() - || (!MissionControl[infantry->Mission].IsRecruitable && Session.Type == GAME_NORMAL)) + || (!(infantry->Mission >= 0 && MissionControl[infantry->Mission].IsRecruitable) + && Session.Type == GAME_NORMAL)) continue; // (Mission != MISSION_GUARD_AREA || Session.Type == GAME_NORMAL)) continue; @@ -5429,7 +5430,8 @@ bool TechnoClass::Evaluate_Object(ThreatType method, ** Never recruit sticky guard units to defend a base. */ if (!unit->Is_Weapon_Equipped() - || (!MissionControl[unit->Mission].IsRecruitable && Session.Type == GAME_NORMAL)) + || (!(unit->Mission >= 0 && MissionControl[unit->Mission].IsRecruitable) + && Session.Type == GAME_NORMAL)) continue; /*