Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 2706612

Browse files
committed
[ CID 15464 ] Fix incorrect deallocator issue
1 parent 56390d1 commit 2706612

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

engine/src/control.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,15 +1613,20 @@ Boolean MCControl::moveable()
16131613

16141614
void MCControl::newmessage()
16151615
{
1616-
char *messptr = new char[strlen(gettypestring()) + 4];
1617-
strcpy(messptr, "new");
1618-
strcpy(&messptr[3], gettypestring());
1619-
1620-
MCAutoNameRef t_message;
1621-
/* UNCHECKED */ t_message . CreateWithCString(messptr);
1622-
message(t_message);
1616+
bool t_success;
1617+
t_success = true;
1618+
1619+
MCAutoStringRef t_message_str;
1620+
if (t_success)
1621+
t_success = MCStringFormat(&t_message_str, "new%s", gettypestring());
1622+
1623+
MCNewAutoNameRef t_message;
1624+
if (t_success)
1625+
t_success = MCNameCreate(*t_message_str, &t_message);
1626+
1627+
if (t_success)
1628+
message(*t_message);
16231629

1624-
delete messptr;
16251630
if (gettype() == CT_GROUP)
16261631
message(MCM_new_background);
16271632
}

0 commit comments

Comments
 (0)