MACVENTURE: Fix leak on loadControls

This commit is contained in:
Borja Lorente 2016-08-13 18:13:29 +02:00
parent 2f2d9bead7
commit 28698ba697
2 changed files with 6 additions and 4 deletions

View File

@ -69,7 +69,7 @@ struct ControlData {
ControlAction refcon; ControlAction refcon;
ControlType type; ControlType type;
uint8 titleLength; uint8 titleLength;
char* title; Common::String title;
uint16 border; uint16 border;
}; };

View File

@ -512,9 +512,11 @@ bool Gui::loadControls() {
data.type = (ControlType)id; id++; data.type = (ControlType)id; id++;
data.titleLength = res->readByte(); data.titleLength = res->readByte();
if (data.titleLength) { if (data.titleLength) {
data.title = new char[data.titleLength + 1]; char *title = new char[data.titleLength + 1];
res->read(data.title, data.titleLength); res->read(title, data.titleLength);
data.title[data.titleLength] = '\0'; title[data.titleLength] = '\0';
data.title = Common::String(title);
delete[] title;
} }
if (data.type != kControlExitBox) { if (data.type != kControlExitBox) {
BorderBounds bbs = borderBounds(getWindowData(kCommandsWindow).type); BorderBounds bbs = borderBounds(getWindowData(kCommandsWindow).type);