Re: FreeBSD's malloc problem ?

From: Anton Alin-Adrian (aanton_at_reversedhell.net)
Date: 04/24/04

  • Next message: Daniel Ellard: "Re: FreeBSD's malloc problem ?"
    Date: Sat, 24 Apr 2004 21:58:34 +0300
    To: freebsd-hackers@freebsd.org
    
    

    Nicolas Rachinsky wrote:
    > * Anton Alin-Adrian <aanton@reversedhell.net> [2004-04-24 21:27 +0300]:
    >
    >> tmp = (char *) malloc(strlen(s)); // line 68
    >
    >
    > Hmm, you need strlen(s)+1 bytes to store the string -- don't forget
    > the trailing null byte.
    >
    > Nicolas

    And let there be light... DANG.. well it almost blinded me. I was confusing
    with char[16], which has the +1 byte for the null terminating, but the
    malloc(16) hasn't...

    Probably doesn't crash on Linux because the malloced space is not adjacent.

    Thanks for the candle.

    Appologises to everyone.

    -- 
    Alin-Adrian Anton
    Reversed Hell Networks
    GPG keyID 0x1E2FFF2E (2963 0C11 1AF1 96F6 0030 6EE9 D323 639D 1E2F FF2E)
    gpg --keyserver pgp.mit.edu --recv-keys 1E2FFF2E
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
    

  • Next message: Daniel Ellard: "Re: FreeBSD's malloc problem ?"