Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Apr 2004 21:58:34 +0300
From:      Anton Alin-Adrian <aanton@reversedhell.net>
To:        freebsd-hackers@freebsd.org
Subject:   Re: FreeBSD's malloc problem ?
Message-ID:  <408AB8DA.2070209@reversedhell.net>
In-Reply-To: <20040424184418.GA25917@pc5.i.0x5.de>
References:  <408AB18B.9020906@reversedhell.net> <20040424184418.GA25917@pc5.i.0x5.de>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?408AB8DA.2070209>