@@ -50,8 +50,6 @@ extern "C" MC_DLLEXPORT void MCListExecPushSingleElementOnto(MCValueRef p_value,
5050 return ;
5151
5252 MCValueAssign (x_target, *t_immutable);
53-
54- // ctxt . Throw();
5553}
5654
5755extern " C" MC_DLLEXPORT void MCListExecPopElementInto (bool p_is_front, MCProperListRef& x_source, MCValueRef& r_output)
@@ -76,8 +74,6 @@ extern "C" MC_DLLEXPORT void MCListExecPopElementInto(bool p_is_front, MCProperL
7674 return ;
7775
7876 MCValueAssign (x_source, *t_immutable);
79-
80- // ctxt . Throw();
8177}
8278
8379extern " C" MC_DLLEXPORT void MCListEvalNumberOfElementsIn (MCProperListRef p_target, uindex_t & r_output)
@@ -102,11 +98,11 @@ extern "C" MC_DLLEXPORT void MCListFetchElementOf(index_t p_index, MCProperListR
10298 uindex_t t_start, t_count;
10399 MCChunkGetExtentsOfElementChunkByExpression (p_target, p_index, t_start, t_count);
104100
105- if (t_count == 0 )
106- return ;
107-
108- if (t_start + t_count > MCProperListGetLength (p_target))
101+ if (t_count == 0 || t_start + t_count > MCProperListGetLength (p_target))
102+ {
103+ MCErrorCreateAndThrow (kMCGenericErrorTypeInfo , " reason" , MCSTR (" chunk index out of range" ), nil);
109104 return ;
105+ }
110106
111107 r_output = MCValueRetain (MCProperListFetchElementAtIndex (p_target, t_start));
112108}
@@ -116,11 +112,11 @@ extern "C" MC_DLLEXPORT void MCListStoreElementOf(MCValueRef p_value, index_t p_
116112 uindex_t t_start, t_count;
117113 MCChunkGetExtentsOfElementChunkByExpression (x_target, p_index, t_start, t_count);
118114
119- if (t_count == 0 )
120- return ;
121-
122- if (t_start + t_count > MCProperListGetLength (x_target))
115+ if (t_count == 0 || t_start + t_count > MCProperListGetLength (x_target))
116+ {
117+ MCErrorCreateAndThrow (kMCGenericErrorTypeInfo , " reason" , MCSTR (" chunk index out of range" ), nil);
123118 return ;
119+ }
124120
125121 MCAutoProperListRef t_mutable_list;
126122 if (!MCProperListMutableCopy (x_target, &t_mutable_list))
@@ -141,11 +137,11 @@ extern "C" MC_DLLEXPORT void MCListFetchElementRangeOf(index_t p_start, index_t
141137 uindex_t t_start, t_count;
142138 MCChunkGetExtentsOfElementChunkByRange (p_target, p_start, p_finish, t_start, t_count);
143139
144- if (t_count == 0 )
145- return ;
146-
147- if (t_start + t_count > MCProperListGetLength (p_target))
140+ if (t_count == 0 || t_start + t_count > MCProperListGetLength (p_target))
141+ {
142+ MCErrorCreateAndThrow (kMCGenericErrorTypeInfo , " reason" , MCSTR (" chunk index out of range" ), nil);
148143 return ;
144+ }
149145
150146 MCProperListCopySublist (p_target, MCRangeMake (t_start, t_count), r_output);
151147}
@@ -155,11 +151,11 @@ extern "C" MC_DLLEXPORT void MCListStoreElementRangeOf(MCValueRef p_value, index
155151 uindex_t t_start, t_count;
156152 MCChunkGetExtentsOfElementChunkByRange (x_target, p_start, p_finish, t_start, t_count);
157153
158- if (t_count == 0 )
159- return ;
160-
161- if (t_start + t_count > MCProperListGetLength (x_target))
154+ if (t_count == 0 || t_start + t_count > MCProperListGetLength (x_target))
155+ {
156+ MCErrorCreateAndThrow (kMCGenericErrorTypeInfo , " reason" , MCSTR (" chunk index out of range" ), nil);
162157 return ;
158+ }
163159
164160 MCAutoProperListRef t_mutable_list;
165161 if (!MCProperListMutableCopy (x_target, &t_mutable_list))
@@ -191,11 +187,11 @@ extern "C" MC_DLLEXPORT void MCListStoreAfterElementOf(MCValueRef p_value, index
191187 t_start += t_count;
192188 MCChunkGetExtentsOfElementChunkByExpression (x_target, p_index, t_start, t_count);
193189
194- if (t_count == 0 )
195- return ;
196-
197- if (t_start + t_count > MCProperListGetLength (x_target))
190+ if (t_count == 0 || t_start + t_count > MCProperListGetLength (x_target))
191+ {
192+ MCErrorCreateAndThrow (kMCGenericErrorTypeInfo , " reason" , MCSTR (" chunk index out of range" ), nil);
198193 return ;
194+ }
199195
200196 MCAutoProperListRef t_mutable_list;
201197 if (!MCProperListMutableCopy (x_target, &t_mutable_list))
@@ -215,11 +211,11 @@ extern "C" MC_DLLEXPORT void MCListStoreBeforeElementOf(MCValueRef p_value, inde
215211 uindex_t t_start, t_count;
216212 MCChunkGetExtentsOfElementChunkByExpression (x_target, p_index, t_start, t_count);
217213
218- if (t_count == 0 )
219- return ;
220-
221- if (t_start + t_count > MCProperListGetLength (x_target))
214+ if (t_count == 0 || t_start + t_count > MCProperListGetLength (x_target))
215+ {
216+ MCErrorCreateAndThrow (kMCGenericErrorTypeInfo , " reason" , MCSTR (" chunk index out of range" ), nil);
222217 return ;
218+ }
223219
224220 MCAutoProperListRef t_mutable_list;
225221 if (!MCProperListMutableCopy (x_target, &t_mutable_list))
@@ -241,11 +237,11 @@ extern "C" MC_DLLEXPORT void MCListSpliceIntoElementRangeOf(MCProperListRef p_li
241237 uindex_t t_start, t_count;
242238 MCChunkGetExtentsOfElementChunkByRange (x_target, p_start, p_finish, t_start, t_count);
243239
244- if (t_count == 0 )
245- return ;
246-
247- if (t_start + t_count > MCProperListGetLength (x_target))
240+ if (t_count == 0 || t_start + t_count > MCProperListGetLength (x_target))
241+ {
242+ MCErrorCreateAndThrow (kMCGenericErrorTypeInfo , " reason" , MCSTR (" chunk index out of range" ), nil);
248243 return ;
244+ }
249245
250246 MCAutoProperListRef t_mutable_list;
251247 if (!MCProperListMutableCopy (x_target, &t_mutable_list))
@@ -271,11 +267,11 @@ extern "C" MC_DLLEXPORT void MCListSpliceBeforeElementOf(MCProperListRef p_list,
271267 uindex_t t_start, t_count;
272268 MCChunkGetExtentsOfElementChunkByExpression (x_target, p_index, t_start, t_count);
273269
274- if (t_count == 0 )
275- return ;
276-
277- if (t_start + t_count > MCProperListGetLength (x_target))
270+ if (t_count == 0 || t_start + t_count > MCProperListGetLength (x_target))
271+ {
272+ MCErrorCreateAndThrow (kMCGenericErrorTypeInfo , " reason" , MCSTR (" chunk index out of range" ), nil);
278273 return ;
274+ }
279275
280276 MCAutoProperListRef t_mutable_list;
281277 if (!MCProperListMutableCopy (x_target, &t_mutable_list))
@@ -295,11 +291,11 @@ extern "C" MC_DLLEXPORT void MCListSpliceAfterElementOf(MCProperListRef p_list,
295291 uindex_t t_start, t_count;
296292 MCChunkGetExtentsOfElementChunkByExpression (x_target, p_index, t_start, t_count);
297293
298- if (t_count == 0 )
299- return ;
300-
301- if (t_start + t_count > MCProperListGetLength (x_target))
294+ if (t_count == 0 || t_start + t_count > MCProperListGetLength (x_target))
295+ {
296+ MCErrorCreateAndThrow (kMCGenericErrorTypeInfo , " reason" , MCSTR (" chunk index out of range" ), nil);
302297 return ;
298+ }
303299
304300 t_start += t_count;
305301
0 commit comments