Fix: memory leak due to assigning result of strdup to a std::string

(cherry picked from commit 296194ad36)
pull/266/head
Rubidium 3 years ago committed by Jonathan G Rennison
parent bf87578173
commit 7c4d803265

@ -7563,7 +7563,7 @@ static void GRFInhibit(ByteReader *buf)
if (file != nullptr && file != _cur.grfconfig) { if (file != nullptr && file != _cur.grfconfig) {
grfmsg(2, "GRFInhibit: Deactivating file '%s'", file->GetDisplayPath()); grfmsg(2, "GRFInhibit: Deactivating file '%s'", file->GetDisplayPath());
GRFError *error = DisableGrf(STR_NEWGRF_ERROR_FORCEFULLY_DISABLED, file); GRFError *error = DisableGrf(STR_NEWGRF_ERROR_FORCEFULLY_DISABLED, file);
error->data = stredup(_cur.grfconfig->GetName()); error->data = _cur.grfconfig->GetName();
} }
} }
} }

@ -54,7 +54,7 @@ CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
si->y = y; si->y = y;
si->z = GetSlopePixelZ(x, y); si->z = GetSlopePixelZ(x, y);
if (!StrEmpty(text)) { if (!StrEmpty(text)) {
si->name = stredup(text); si->name = text;
} }
si->UpdateVirtCoord(); si->UpdateVirtCoord();
InvalidateWindowData(WC_SIGN_LIST, 0, 0); InvalidateWindowData(WC_SIGN_LIST, 0, 0);

@ -2228,7 +2228,7 @@ CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
old_generating_world.Restore(); old_generating_world.Restore();
if (t != nullptr && !StrEmpty(text)) { if (t != nullptr && !StrEmpty(text)) {
t->name = stredup(text); t->name = text;
t->UpdateVirtCoord(); t->UpdateVirtCoord();
} }

Loading…
Cancel
Save