From 58c4ce73b9fdc1d67a928e37742510bf49bb7dbc Mon Sep 17 00:00:00 2001 From: Ibrahim Zidan Date: Sat, 4 Apr 2020 02:48:42 +0200 Subject: Fixed a memory violation in quest info caused by accessing -1 index when qi_list vector length is 0 Signed-off-by: Ibrahim Zidan --- src/map/map.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/map/map.c') diff --git a/src/map/map.c b/src/map/map.c index 6ebc50ba3..b2c9c77c3 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -6047,8 +6047,12 @@ static bool map_add_questinfo(int m, struct npc_data *nd) nullpo_retr(false, nd); Assert_retr(false, m >= 0 && m < map->count); - if (VECTOR_LAST(map->list[m].qi_list) == nd) + int i; + ARR_FIND(0, VECTOR_LENGTH(map->list[m].qi_list), i, VECTOR_INDEX(map->list[m].qi_list, i) == nd); + + if (i < VECTOR_LENGTH(map->list[m].qi_list)) { return false; + } VECTOR_ENSURE(map->list[m].qi_list, 1, 1); VECTOR_PUSH(map->list[m].qi_list, nd); -- cgit v1.2.3-60-g2f50