summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2020-05-10 06:55:11 +0300
committerAndrei Karas <akaras@inbox.ru>2020-06-01 01:08:50 +0300
commite5a2fa215dbe6fd329efd3ce5f2cc2f5724973d6 (patch)
tree982c5f5b5ea0f10d7bce58bd27476781e249cc53 /src/map/script.c
parent7c5a4495acf7ce33393a937e097e8d08c2a0cc81 (diff)
downloadhercules-e5a2fa215dbe6fd329efd3ce5f2cc2f5724973d6.tar.gz
hercules-e5a2fa215dbe6fd329efd3ce5f2cc2f5724973d6.tar.bz2
hercules-e5a2fa215dbe6fd329efd3ce5f2cc2f5724973d6.tar.xz
hercules-e5a2fa215dbe6fd329efd3ce5f2cc2f5724973d6.zip
Fix crash in npcshopdelitem script command
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 069b98eef..09e4f3301 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -19152,7 +19152,14 @@ static BUILDIN(npcshopdelitem)
size--;
}
- RECREATE(nd->u.shop.shop_item, struct npc_item_list, size);
+ int alloc_size = size;
+ if (size < 0) {
+ size = 0;
+ alloc_size = 1;
+ } else if (size < 1) {
+ alloc_size = 1;
+ }
+ RECREATE(nd->u.shop.shop_item, struct npc_item_list, alloc_size);
nd->u.shop.count = size;
script_pushint(st,1);