DIRECTOR: LINGO: Fix memory leak

Memory leak happens when a cast is moved but without
specifying the place for it to move to.
Datum constructor gets the castMemberId by copy leaving the
resource to be dealt with by the original function.

- Includes lingo test.

Fixes COVERITY: 1498924
This commit is contained in:
Roland van Laar 2022-10-08 10:28:03 +02:00
parent 8dfe2ccc96
commit 9e4e20962b
2 changed files with 3 additions and 0 deletions

View File

@ -2148,6 +2148,7 @@ void LB::b_move(int nargs) {
int id = (int) g_director->getCurrentMovie()->getCast()->_castArrayStart;
CastMemberID *castId = new CastMemberID(id, 0);
Datum d = Datum(*castId);
delete castId;
g_lingo->push(d);
b_findEmpty(1);
dest = g_lingo->pop();

View File

@ -11,6 +11,8 @@ open "Hello" && "more" with "Finder"
move cast 1, cast 1
move cast 1, 3
move cast 3, 1
move cast 1
put findEmpty(cast 10)
pasteClipBoardInto cast 2
put the width of cast 1