How this program can crash into other applications, as one application can't play with other application address space.
On 08 Mar 2007 05:09:29 -0800, Sumit Chawla <[EMAIL PROTECTED]> wrote: > > On 07 Mar 2007 18:36:56 -0800, Chetan Nanda <[EMAIL > PROTECTED]<chetannanda%40gmail.com>> > wrote: > > > > Hi All, > > Acn anybody explain me the behavior of the following program. > > > > #include <stdio.h> > > int main() > > { > > char *dst = (char *) malloc(4); > > strcpy(dst, "This is a nice palace"); > > > > exit(0); > > } > > > > This is a clear case of memory corruption. But it do not crash. I am > using > > GCC as compiler. > > > > ~nandac > > > > You are crossing the memory bounds and corrupting the memory block which > might have been allocated to other parts of your program or some other > program. It might crash the other programs or applications. So behavior is > undefined. > > -- > Regards > Sumit Chawla ("eNetra : Hail the Invention") > > "Computers are useless. They can only give you answers.":Pablo Picasso > > [Non-text portions of this message have been removed] > > > -- Thanks & Regards Chetan Nanda Software Engineer Conexant System,Noida [Non-text portions of this message have been removed]