summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
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);