fix github issue #110 - sortloot segfault
Fixes #110 NetHack dumped core while qsort was executing for sortloot. Fix a logic error introduced by adding filtering capability to sortloot() which could result in a sparsely populated array instead of having the number of elements be less than the list size. I don't know why this didn't show up sooner.
This commit is contained in:
@@ -53,6 +53,7 @@ Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository
|
||||
fix access violation when --debug:xxxx has no other args after it
|
||||
Setting the inverse attribute for gold had the space before "$:"
|
||||
getting highlighted along with the gold field
|
||||
sortloot segfaulted when filtering a subset of items (seen with 'A' command)
|
||||
|
||||
|
||||
Platform- and/or Interface-Specific Fixes
|
||||
|
||||
@@ -462,7 +462,7 @@ boolean FDECL((*filterfunc), (OBJ_P));
|
||||
augment_filter = (mode & SORTLOOT_PETRIFY) ? TRUE : FALSE;
|
||||
mode &= ~SORTLOOT_PETRIFY; /* remove flag, leaving mode */
|
||||
/* populate aliarray[0..n-1] */
|
||||
for (i = 0, o = *olist; o; ++i, o = by_nexthere ? o->nexthere : o->nobj) {
|
||||
for (i = 0, o = *olist; o; o = by_nexthere ? o->nexthere : o->nobj) {
|
||||
if (filterfunc && !(*filterfunc)(o)
|
||||
/* caller may be asking us to override filterfunc (in order
|
||||
to do a cockatrice corpse touch check during pickup even
|
||||
@@ -473,6 +473,7 @@ boolean FDECL((*filterfunc), (OBJ_P));
|
||||
sliarray[i].obj = o, sliarray[i].indx = (int) i;
|
||||
sliarray[i].str = (char *) 0;
|
||||
sliarray[i].orderclass = sliarray[i].subclass = sliarray[i].disco = 0;
|
||||
++i;
|
||||
}
|
||||
n = i;
|
||||
/* add a terminator so that we don't have to pass 'n' back to caller */
|
||||
|
||||
Reference in New Issue
Block a user