Re: malloc realloc and pointers



In article <474F3665.E22FCDA7@xxxxxxxxxxx>,
Kenneth Brody <kenbrody@xxxxxxxxxxx> wrote:
ravi wrote:

int *variable, value;
*((long*)variable)++ = value;
*((long*)variable)++ = value;
*((long*)variable)++ = value;
*((long*)variable)++ = value;

If variable is properly aligned, I believe it's valid.

variable has not been initialized, so it is a dangling pointer.
--
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth
.



Relevant Pages

  • Re: Writing single bits to a file
    ... Kenneth Brody wrote: ... in fractions of bits; if a file length of 10007 bits is bad, ... "Beware of bugs in the above code; I have only proved it correct, ...
    (comp.lang.c)
  • Re: BDD and TDD - What are they for?
    ... On Sun, 17 Aug 2008, David Masover wrote: ... "Beware of bugs in the following code. ... Rails training from David A. Black and Ruby Power and Light: ...
    (comp.lang.ruby)
  • Re: [Lit.] Buffer overruns
    ... > freed but a dangling pointer to it remains and is later dereferenced. ... > Such bugs can lead to security vulnerabilities. ... thus causing abnormal program termination. ...
    (sci.crypt)
  • Re: CC Holster for FM Hi Power Detective
    ... # "Beware of bugs in the above code; ... # Trenton G. Twining ...
    (rec.guns)
  • Re: structures, using strings
    ... junelogicalvec = strcmp; ... junemembers = MCT; ... "Beware of bugs in the above code; ...
    (comp.soft-sys.matlab)