Re: [CODE] bug fix in zedit new from "Wayde Milas" at Jul 29, 97 01:55:09 pm

From: Andrew Helm (ashe@IGLOU.COM)
Date: 07/30/97


> The correct way:
> rewrite the wole inner and outer loop. I'm not kidding. The logic that it
> uses is totally flawed. (After tracing it :) The previous post that
> suggested +2 is inded correct. It SHOULD be +2 cause thats the correct
> size of the table. The problem is that the inner loop will try and access
> +3 after it has found its insertion point. Or inner if, or whatever. If
> you take the time to sit there and trace it, you can watch it try to
> access outside of the array bounds. If you don['t feel like rwriting it,
> just change the table size to +3 and waste a row of mem. No biggie.
>

  I agree it should just be rewritten. Trying to do it all in one for
loop was a Bad Idea. Not only is it easier to understand if you break
it up into seperate steps, but it's faster and the logic more simple
(hence, the bugs are easier to find).

 As for the +3 solution, it's a bad idea too. It depends on a bug in
boot_index() that allocates an extra element's worth of memory to
the zone_table array. Without that bug, the +3 solution would invoke
undefined behavior when it tried to access zone_table[i] when i is
equal to top_of_zone_table + 1.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST