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

Commit 661ce1f

Browse files
Merge pull request #5448 from runrevmark/bugfix-19681
[[ Bug 19681 ]] Ensure targetptr check is only done if valid before
2 parents eecd7d4 + f104e51 commit 661ce1f

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

engine/src/dispatch.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ Exec_stat MCDispatch::handle(Handler_type htype, MCNameRef mess, MCParameter *pa
246246

247247
if ((stat == ES_NOT_HANDLED || stat == ES_PASS) && m_externals != nil)
248248
{
249+
// TODO[19681]: This can be removed when all engine messages are sent with
250+
// target.
251+
bool t_target_was_valid = MCtargetptr.IsValid();
252+
249253
Exec_stat oldstat = stat;
250254
stat = m_externals -> Handle(this, htype, mess, params);
251255

@@ -259,7 +263,7 @@ Exec_stat MCDispatch::handle(Handler_type htype, MCNameRef mess, MCParameter *pa
259263

260264
if (stat == ES_PASS || stat == ES_NOT_HANDLED)
261265
{
262-
if (!MCtargetptr.IsValid())
266+
if (t_target_was_valid && !MCtargetptr.IsValid())
263267
{
264268
stat = ES_NORMAL;
265269
t_has_passed = false;
@@ -292,12 +296,16 @@ Exec_stat MCDispatch::handle(Handler_type htype, MCNameRef mess, MCParameter *pa
292296

293297
if ((stat == ES_NOT_HANDLED || stat == ES_PASS))
294298
{
299+
// TODO[19681]: This can be removed when all engine messages are sent with
300+
// target.
301+
bool t_target_was_valid = MCtargetptr.IsValid();
302+
295303
extern Exec_stat MCEngineHandleLibraryMessage(MCNameRef name, MCParameter *params);
296304
stat = MCEngineHandleLibraryMessage(mess, params);
297305

298306
if (stat == ES_PASS || stat == ES_NOT_HANDLED)
299307
{
300-
if (!MCtargetptr.IsValid())
308+
if (t_target_was_valid && !MCtargetptr.IsValid())
301309
{
302310
stat = ES_NORMAL;
303311
t_has_passed = false;

engine/src/object.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,10 @@ Exec_stat MCObject::handleself(Handler_type p_handler_type, MCNameRef p_message,
10771077
Exec_stat t_stat;
10781078
t_stat = ES_NOT_HANDLED;
10791079

1080+
// TODO[19681]: This can be removed when all engine messages are sent with
1081+
// target.
1082+
bool t_target_was_valid = MCtargetptr.IsValid();
1083+
10801084
MCObjectExecutionLock self_lock(this);
10811085

10821086
// Make sure this object has its script compiled.
@@ -1140,7 +1144,7 @@ Exec_stat MCObject::handleself(Handler_type p_handler_type, MCNameRef p_message,
11401144

11411145
if (t_stat == ES_PASS || t_stat == ES_NOT_HANDLED)
11421146
{
1143-
if (!MCtargetptr.IsValid())
1147+
if (t_target_was_valid && !MCtargetptr.IsValid())
11441148
{
11451149
t_main_stat = ES_NORMAL;
11461150
}

engine/src/stack.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,13 +1592,17 @@ Exec_stat MCStack::handle(Handler_type htype, MCNameRef message, MCParameter *pa
15921592

15931593
if (((passing_object != nil && stat == ES_PASS) || stat == ES_NOT_HANDLED) && m_externals != nil)
15941594
{
1595+
// TODO[19681]: This can be removed when all engine messages are sent with
1596+
// target.
1597+
bool t_target_was_valid = MCtargetptr.IsValid();
1598+
15951599
Exec_stat oldstat = stat;
15961600
stat = m_externals -> Handle(this, htype, message, params);
15971601
if (oldstat == ES_PASS && stat == ES_NOT_HANDLED)
15981602
stat = ES_PASS;
15991603
if (stat == ES_PASS || stat == ES_NOT_HANDLED)
16001604
{
1601-
if (!MCtargetptr.IsValid())
1605+
if (t_target_was_valid && !MCtargetptr.IsValid())
16021606
{
16031607
stat = ES_NORMAL;
16041608
}

0 commit comments

Comments
 (0)