mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
added sanity check for AddItem arguments
This commit is contained in:
parent
589f8b5ede
commit
db24a55e36
@ -1,6 +1,8 @@
|
||||
|
||||
#include "containerextensions.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <components/compiler/extensions.hpp>
|
||||
|
||||
#include <components/interpreter/interpreter.hpp>
|
||||
@ -32,6 +34,9 @@ namespace MWScript
|
||||
Interpreter::Type_Integer count = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
if (count<0)
|
||||
throw std::runtime_error ("second argument for AddItem must be non-negative");
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWWorld::ManualRef ref (context.getWorld().getStore(), item);
|
||||
@ -61,6 +66,9 @@ namespace MWScript
|
||||
Interpreter::Type_Integer count = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
if (count<0)
|
||||
throw std::runtime_error ("second argument for AddItem must be non-negative");
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWWorld::ManualRef ref (context.getWorld().getStore(), item);
|
||||
|
Loading…
x
Reference in New Issue
Block a user