Re: [CODE] Zedit (yea, again...)

From: Robert Sinland (rsinland@ERSKINE.POLARISTEL.NET)
Date: 07/23/97

Wayde Milas wrote:

> Question. Isn't the second line totally wrong? if you calloc an array of
> top_of_zone_table size, and then you set an element in
> new_table[top_of_zone_table + 1] (number) aren't you WAY past the end of
> the new array that you allocated?
> Not only that... but you are actually 2 spaces past it since you have to
> consider that they array starts at [0].
> So, is it me, or does this piece of code look totally fubared? I think its
> time for me to re-write it. :)
> Wayde

    This is just a cut and paste from another post someone else made.  I
did not write this, but it may help answer your question....

My "zedit new <vnum>" now works after the following change:

The fix is in zedit.c line 1174 :
  /*. Make a new zone in memory.*/
  CREATE(new_table, struct zone_data, top_of_zone_table);
  new_table[top_of_zone_table + 1].number = 32000;
  /*. Make a new zone in memory.*/
  CREATE(new_table, struct zone_data,  top_of_zone_table+3);
  new_table[top_of_zone_table + 1].number = 32000;

I found the problem using purify, which just kept reporting that i was
writing above the array bounds in new_table[], so i kept incrementing it
until there were no more errors. I can understand why it should be
top_of_zone_table+1, but why +3? (+1 and +2 still reported Array Bounds
Write errors)

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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