From 7c4d8032651624995035af81f2c8dc3a0b74f855 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sun, 9 May 2021 22:51:26 +0200 Subject: [PATCH] Fix: memory leak due to assigning result of strdup to a std::string (cherry picked from commit 296194ad36c601cf12d215a65d84222bbdf4de61) --- src/newgrf.cpp | 2 +- src/signs_cmd.cpp | 2 +- src/town_cmd.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index ce2f9b44f0..5858ebacb6 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -7563,7 +7563,7 @@ static void GRFInhibit(ByteReader *buf) if (file != nullptr && file != _cur.grfconfig) { grfmsg(2, "GRFInhibit: Deactivating file '%s'", file->GetDisplayPath()); GRFError *error = DisableGrf(STR_NEWGRF_ERROR_FORCEFULLY_DISABLED, file); - error->data = stredup(_cur.grfconfig->GetName()); + error->data = _cur.grfconfig->GetName(); } } } diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp index 5006a33f73..89bd943f69 100644 --- a/src/signs_cmd.cpp +++ b/src/signs_cmd.cpp @@ -54,7 +54,7 @@ CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 si->y = y; si->z = GetSlopePixelZ(x, y); if (!StrEmpty(text)) { - si->name = stredup(text); + si->name = text; } si->UpdateVirtCoord(); InvalidateWindowData(WC_SIGN_LIST, 0, 0); diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 7faac62eee..6e304e8da9 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2228,7 +2228,7 @@ CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 old_generating_world.Restore(); if (t != nullptr && !StrEmpty(text)) { - t->name = stredup(text); + t->name = text; t->UpdateVirtCoord(); }