Re: [CODE] CREATE() buglet

From: Dean Takemori (dean@UHHEPH.PHYS.HAWAII.EDU)
Date: 07/07/98


Angus Mezick <angus@EDGIL.CCMAIL.COMPUSERVE.COM> wrote:
>why are you trying to call CREATE with 0 or a negative number anyway?  C will

num = strlen(somestring) + 1;
accidentally_zero_num();
p = (char*)malloc(num);
if (p == NULL) { abort(); }

Contrived example addmittedly, but this will bomb immediately on
some systems and silently corrupt memory in others.

"d. hall" <dhall@OOI.NET> wrote:
>Quite a few programmers make wrappers for malloc to one: assert(3) that
>requested length is > 0, and if the return is non-null.  Quite of few

And this is what CREATE() is, so we should be complete and check for
num > 0.  Values that when cast to signed are negative are another
issue.


     +------------------------------------------------------------+
     | 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/15/00 PST