View Single Post
Old May 8, 2017, 22:14   #91
Vanilla maintainer
Nick's Avatar
Join Date: Apr 2007
Location: Canberra, Australia
Age: 55
Posts: 8,757
Donated: $60
Nick will become famous soon enough
Originally Posted by t4nk View Post
Nick, I got a crash from asan at obj-randart.c:2518:
while (strstr(art->name, "The One Ring") ||
	kf_has(kind->kind_flags, KF_QUEST_ART)) {
	art = &a_info[*aidx];
	art_level = art->level;
	if ((*aidx) >= z_info->a_max) {
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.

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