minetest-mods / drawers

[MTG/MCL2] A Minetest Mod adding storage drawers in different sizes and wood types.
Other
19 stars 26 forks source link

`dropPos` related crash on `nodemeta_inventory_OnTake()` #59

Closed BuckarooBanzay closed 3 years ago

BuckarooBanzay commented 3 years ago
2021-04-17 09:29:34: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'drawers' in callback nodemeta_inventory_OnTake(): /data/world//worldmods/drawers/lua/visual.lua:378: attempt to index local 'dropPos' (a nil value)
2021-04-17 09:29:34: ERROR[Main]: stack traceback:
2021-04-17 09:29:34: ERROR[Main]:   /data/world//worldmods/drawers/lua/visual.lua:378: in function 'dropStack'
2021-04-17 09:29:34: ERROR[Main]:   /data/world//worldmods/drawers/lua/visual.lua:402: in function 'dropItemOverload'
2021-04-17 09:29:34: ERROR[Main]:   /data/world//worldmods/drawers/lua/visual.lua:411: in function 'setStackMaxFactor'
2021-04-17 09:29:34: ERROR[Main]:   /data/world//worldmods/drawers/lua/helpers.lua:263: in function 'f'
2021-04-17 09:29:34: ERROR[Main]:   /data/world//worldmods/monitoring/metrictypes/counter.lua:42: in function 'update_drawer_upgrades'
2021-04-17 09:29:34: ERROR[Main]:   /data/world//worldmods/drawers/lua/api.lua:177: in function </data/world//worldmods/drawers/lua/api.lua:173>
OgelGames commented 3 years ago

https://github.com/minetest-mods/drawers/blob/cbb5f42e7af5bfa6e3450932c6f0a2e53d83886f/lua/visual.lua#L374-L379

The drawer that caused this crash was surrounded by vacuum:vacuum nodes, so getting a drop position from find_node_near fails, and then dropPos is incorrectly set to self.pos, which is also a nil value.

Changing line 377 to this should fix it: (untested)

dropPos = self.object:get_pos()