Skip to content

Commit 2ac7715

Browse files
author
Ali Lloyd
committed
[[ RefactorSyntax ]] Fix various issues with values and reference counts
1 parent a0821f4 commit 2ac7715

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

engine/src/cmdsm.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,12 +1369,14 @@ void MCSetOp::exec_ctxt(MCExecContext &ctxt)
13691369
if (!ctxt . EvalExprAsValueRef(source, EE_ARRAYOP_BADEXP, &t_src_value))
13701370
return;
13711371

1372+
MCValueRef t_source;
1373+
13721374
if (!MCValueIsArray(*t_src_value))
1373-
{
1374-
MCValueRelease(*t_src_value);
1375-
MCValueCopy((MCValueRef)kMCEmptyString, &t_src_value);
1376-
}
1377-
1375+
t_source = kMCEmptyString;
1376+
else
1377+
t_source = *t_src_value;
1378+
1379+
13781380
MCAutoPointer<MCContainer> t_container;
13791381
if (!destvar -> evalcontainer(ctxt, &t_container))
13801382
{
@@ -1393,7 +1395,7 @@ void MCSetOp::exec_ctxt(MCExecContext &ctxt)
13931395
return;
13941396

13951397
MCAutoArrayRef t_src_array;
1396-
if (!ctxt . ConvertToArray(*t_src_value, &t_src_array))
1398+
if (!ctxt . ConvertToArray(t_source, &t_src_array))
13971399
return;
13981400

13991401
if (intersect)

engine/src/exec-array.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void MCArraysDoUnion(MCExecContext& ctxt, MCArrayRef p_dst_array, MCArrayRef p_s
228228
continue;
229229
}
230230

231-
if (!MCArrayStoreValue(p_dst_array, ctxt . GetCaseSensitive(), t_key, t_src_value))
231+
if (!MCArrayStoreValue(p_dst_array, ctxt . GetCaseSensitive(), t_key, MCValueRetain(t_src_value)))
232232
{
233233
ctxt . Throw();
234234
return;

engine/src/exec.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,13 +2493,10 @@ void MCExecStoreProperty(MCExecContext& ctxt, const MCPropertyInfo *prop, void *
24932493
{
24942494
MCExecEnumTypeInfo *t_enum_info;
24952495
t_enum_info = (MCExecEnumTypeInfo *)prop -> type_info;
2496-
2497-
MCAutoStringRef t_string;
2498-
MCExecTypeConvertAndReleaseAlways(ctxt, p_value . type, &p_value, kMCExecValueTypeStringRef, &(&t_string));
2499-
2496+
25002497
intenum_t t_value;
25012498
intenum_t* t_value_ptr;
2502-
if (MCStringIsEmpty(*t_string))
2499+
if (p_value . type == kMCExecValueTypeValueRef && MCValueIsEmpty(p_value . valueref_value))
25032500
t_value_ptr = nil;
25042501
else
25052502
{

0 commit comments

Comments
 (0)