@@ -172,16 +172,16 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
172
172
Inventory *inv_from = mgr->getInventory (from_inv);
173
173
Inventory *inv_to = mgr->getInventory (to_inv);
174
174
175
- if (!inv_from){
176
- infostream<< " IMoveAction::apply(): FAIL: source inventory not found: "
177
- << " from_inv=\" " <<from_inv.dump ()<< " \" "
178
- << " , to_inv=\" " << to_inv.dump ()<< " \" " << std::endl;
175
+ if (!inv_from) {
176
+ infostream << " IMoveAction::apply(): FAIL: source inventory not found: "
177
+ << " from_inv=\" " <<from_inv.dump () << " \" "
178
+ << " , to_inv=\" " << to_inv.dump () << " \" " << std::endl;
179
179
return ;
180
180
}
181
- if (!inv_to){
182
- infostream<< " IMoveAction::apply(): FAIL: destination inventory not found: "
183
- << " from_inv=\" " << from_inv.dump ()<< " \" "
184
- << " , to_inv=\" " << to_inv.dump ()<< " \" " << std::endl;
181
+ if (!inv_to) {
182
+ infostream << " IMoveAction::apply(): FAIL: destination inventory not found: "
183
+ << " from_inv=\" " << from_inv.dump () << " \" "
184
+ << " , to_inv=\" " << to_inv.dump () << " \" " << std::endl;
185
185
return ;
186
186
}
187
187
@@ -191,16 +191,16 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
191
191
/*
192
192
If a list doesn't exist or the source item doesn't exist
193
193
*/
194
- if (!list_from){
195
- infostream<< " IMoveAction::apply(): FAIL: source list not found: "
196
- << " from_inv=\" " << from_inv.dump ()<< " \" "
197
- << " , from_list=\" " << from_list<< " \" " << std::endl;
194
+ if (!list_from) {
195
+ infostream << " IMoveAction::apply(): FAIL: source list not found: "
196
+ << " from_inv=\" " << from_inv.dump () << " \" "
197
+ << " , from_list=\" " << from_list << " \" " << std::endl;
198
198
return ;
199
199
}
200
- if (!list_to){
201
- infostream<< " IMoveAction::apply(): FAIL: destination list not found: "
202
- << " to_inv=\" " <<to_inv.dump ()<< " \" "
203
- << " , to_list=\" " << to_list<< " \" " << std::endl;
200
+ if (!list_to) {
201
+ infostream << " IMoveAction::apply(): FAIL: destination list not found: "
202
+ << " to_inv=\" " <<to_inv.dump () << " \" "
203
+ << " , to_list=\" " << to_list << " \" " << std::endl;
204
204
return ;
205
205
}
206
206
@@ -246,6 +246,13 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
246
246
move_somewhere = true ;
247
247
return ;
248
248
}
249
+
250
+ if ((u16)to_i > list_to->getSize ()) {
251
+ infostream << " IMoveAction::apply(): FAIL: destination index out of bounds: "
252
+ << " to_i=" << to_i
253
+ << " , size=" << list_to->getSize () << std::endl;
254
+ return ;
255
+ }
249
256
/*
250
257
Do not handle rollback if both inventories are that of the same player
251
258
*/
0 commit comments