On Mon, 8 Mar 1999, Richard Glover wrote:
> Just curious, but where in this do you see a check for NULL?
I now quote what he said,
> >used. Plus the Circle version can catch null strings, strdup() would
and point out your misinterpretation. He didn't say str_dup() *does*, he
said it *can*. Unless you're going to recompile your C library, you can't
make strdup() NULL safe. You can, however, make str_dup() NULL safe.
Although why you'd want to isn't clear to me -- crashes aren't always bad
things. If str_dup() is being called with a NULL string, which isn't
supposed to happen in most cases, then a crash with a core dump is useful.
If you don't want it to crash, then check if the string being passed to
str_dup() is NULL beforehand. You can keep the MUD up by reporting an
error and just returning some standard string in str_dup(), but this
probably isn't desirable for all the potential uses of str_dup(). So just
let it crash instead of letting your broken code run and potentially
corrupt data.
-dak
+------------------------------------------------------------+
| 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