OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: marco (slasharbornet.org)
Date: Tue Feb 05 2002 - 20:38:49 CST

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    Marc,

    Someone correctly pointed out to the folowing to me: "Now you have
    created yet another person who will fix his lack of understanding of
    pointers with sprinkling malloc everywhere."

    Since I feel responsible for this please read this pretty good tutorial
    on pointers: http://pw1.netcom.com/~tjensen/ptr/pointers.htm

    One last thing, ALLWAYS free a piece of memory that you used before. So
    your code needs:
    free(p);
    at the end of the code.

    /marco

    PS: I won't reply to these anymore!

    ----- Original Message -----
    From: "marco" <slasharbornet.org>
    To: "Marc Xander Makkes" <xanderkr85.org>; <miscopenbsd.org>
    Sent: Tuesday, February 05, 2002 7:43 PM
    Subject: Re: Why the hell is my code coredumping ?

    > Well, I am surprised it does not core dump on solaris.
    >
    > You might want to consider to assign the pointer or allocate some
    memory
    > for it.
    >
    > struct point pt;
    > p = &pt;
    >
    > or
    >
    > p = malloc(sizeof(point));
    >
    > I bet it tries to assign #13 to $0.
    >
    > /marco
    >
    > ----- Original Message -----
    > From: "Marc Xander Makkes" <xanderkr85.org>
    > To: <miscopenbsd.org>
    > Sent: Tuesday, February 05, 2002 6:48 PM
    > Subject: Why the hell is my code coredumping ?
    >
    >
    > > I have this little code;
    > >
    > > +----
    > >
    > >
    > > #include <stdio.h>
    > >
    > > struct point { int x; int y;};
    > > int main()
    > > {
    > > struct point *p;
    > > p->y = 13;
    > > printf("%d\n", p->y);
    > > }
    > >
    > >
    > > ----+
    > >
    > > it compiles and runs ok on solaris, and it compiles ok on openbsd
    but
    > > when i run it, it directly core dumpes. Is there something i forgot
    to
    > > read or is it the 13?:)
    > >
    > > The code is compiled on 2 differend OpenBSD 3.0 machines, one with
    > GENERIC
    > > and one modified, both i386.
    > >
    > >
    > > any clues ?
    > >
    > > Kind regards,
    > >
    > >
    > > MX