View Single Post
Old May 8, 2017, 23:14   #91
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 55
Posts: 8,638
Donated: $60
Nick will become famous soon enough
Quote:
Originally Posted by t4nk View Post
Nick, I got a crash from asan at obj-randart.c:2518:
Code:
while (strstr(art->name, "The One Ring") ||
	kf_has(kind->kind_flags, KF_QUEST_ART)) {
	(*aidx)++;
	art = &a_info[*aidx];
	art_level = art->level;
	if ((*aidx) >= z_info->a_max) {
		return;
	}
}
obj-init.c allocates z_info->a_max + 1 structs (line 2700), but note that it then increments a_max (line 2715). So accessing art->level when *aidx == a_max is illegal (perhaps that's the cause of Nomad's crash?)
Thank you, yes - I should be testing before incrementing.

Quote:
Originally Posted by t4nk View Post
(come to think of it, why does obj-init.c do that? and why does it start assigning from a_max, leaving zeroed out struct at the beginning?)
I don't actually remember. Each artifact in artifact.txt used to have an index, and they started at 1, and there was some code or other that relied on that fact, but I'm not at all sure it's necessary any more. I'll check at some point and change it if it's not needed, because it's a bit silly to do it for no reason.
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote