Hi,
I have another question about the new dgscripts pl8 for bpl21
again sorry if this has been posted before, I haven't quite caught up yet, a short search in the archives didnt turn up anything.
in dg_scripts.c:3228
I get a seg fault there, btw im on a fresh bpl21, olc2.0.1 bpl21, dg scripts pl8.
It would happen when i would trigedit a non-existant vnum.
ie trigedit 5700 (zone 57 exists btw 5700-5799)
int real_trigger(int vnum)
{
int bot = 0, mid;
int top = top_of_trigt;
/* perform binary search on trigger-table */
for (;;) {
mid = (bot + top) / 2;
if (trig_index[mid]->vnum == vnum) <----- right here
return (mid);
if (bot >= top)
return (NOTHING);
if (trig_index[mid]->vnum > vnum)
top = mid - 1;
else
bot = mid + 1;
}
}
The debugger reports that mid = 20 when it faults, and trig_index is only 20 elements big,(b/c 0.trg has only 20 triggers) so its end element is [19]. So it's crashing b/c its pointer has wandered off the array into nowhere.
I fixed it by changing
int top = top_of_trigt;
to
int top = top_of_trigt-1;
anyone else fix this in a different way? I feel like this is a quick and dirty fix.
thanks,
rj
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
| Newbie List: http://groups.yahoo.com/group/circle-newbies/ |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/25/03 PDT