Re: [SYSTEM-WIN95] borland, sprintf, autoexit

From: George (greerga@CIRCLEMUD.ORG)
Date: 12/14/97


On Sat, 13 Dec 1997, Erwin S. Andreasen wrote:

>On Sat, 13 Dec 1997, Kingmundi wrote:
>
>> sprintf(buf, "%s %s ", buf, dirs[door]);
>> send_to_char(buf, ch);
>
>The above code produces undefined results. You have no guarantee that
>sprintf will read its arguments before it starts doing something to the
>output buffer. In theory, the compiler writer is allowed to blow up your
>computer when encountering such code. Unfortunately, few choose to do so

That would probably result because Borland decides to NUL the buffer before
beginning the copy.  Every other system I've seen will just copy the string
on top of itself causing the desired behavior.

Ah well...something to do for a future pl.

--
George Greer  -  Me@Null.net   | Genius may have its limitations, but stupidity
http://www.van.ml.org/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | 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