[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: RE : [cobalt-developers] Help: error when reading a file with C++
- Subject: RE: RE : [cobalt-developers] Help: error when reading a file with C++
- From: "Chris R. Burton" <Chris@xxxxxxxxxxx>
- Date: Tue Sep 24 08:24:25 2002
- List-id: Discussion Forum for developers on Sun Cobalt Networks products <cobalt-developers.list.cobalt.com>
>If I declare the char * buf before calling open(...), it runs.
>Else if I declare char * buf = new char after calling open(...), it
runs
>so.
>It seems strange, no ?
Not strange at all, what you've just coded is a buffer overflow waiting
to happen.
You will need to use new/malloc to allocate the memory for the "char"
you are pointing buf towards. Or define buf in a way that allocates
space for it, instead of space for a pointer.
ChrisB.