Re: strdup or str_dup?

From: Acido (acido@dvmud.net)
Date: 03/09/99


At 06:56 PM 3/8/99 -0800, you wrote:
>Just curious, but where in this do you see a check for NULL?
>
>/* Create a duplicate of a string */
>char *str_dup(const char *source)
>{
>  char *new_z;
>
>  CREATE(new_z, char, strlen(source) + 1);
>  return (strcpy(new_z, source));
>}
>
>#define CREATE(result, type, number)  do {\
> if ((number) * sizeof(type) <= 0) \
>  log("SYSERR: Zero bytes or less requested at %s:%d.", __FILE__, __LINE__);
>\
> if (!((result) = (type *) calloc ((number), sizeof(type)))) \
>  { perror("SYSERR: malloc failure"); abort(); } } while(0)
>
>I've sent a NULL here and every time it crashes.

There's a NULL check in bpl15


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



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