From owner-freebsd-hackers@FreeBSD.ORG Sat Apr 24 11:58:36 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6F5F816A4CE for ; Sat, 24 Apr 2004 11:58:36 -0700 (PDT) Received: from mail.1plan.net (ns1.1plan.net [216.240.143.74]) by mx1.FreeBSD.org (Postfix) with SMTP id 3E3BC43D3F for ; Sat, 24 Apr 2004 11:58:36 -0700 (PDT) (envelope-from aanton@reversedhell.net) Received: (qmail 41221 invoked by uid 98); 24 Apr 2004 19:04:36 -0000 Received: from aanton@reversedhell.net by cp by uid 101 with qmail-scanner-1.20 (clamscan: 0.65. Clear:RC:1(81.196.32.25):SA:0(-100.0/5.0):. Processed in 1.52002 secs); 24 Apr 2004 19:04:36 -0000 X-Spam-Status: No, hits=-100.0 required=5.0 X-Qmail-Scanner-Mail-From: aanton@reversedhell.net via cp X-Qmail-Scanner: 1.20 (Clear:RC:1(81.196.32.25):SA:0(-100.0/5.0):. Processed in 1.52002 secs) Received: from unknown (HELO reversedhell.net) (81.196.32.25) by ns1.1plan.net with SMTP; 24 Apr 2004 19:04:34 -0000 Message-ID: <408AB8DA.2070209@reversedhell.net> Date: Sat, 24 Apr 2004 21:58:34 +0300 From: Anton Alin-Adrian User-Agent: Mozilla Thunderbird 0.5 (X11/20040303) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-hackers@freebsd.org References: <408AB18B.9020906@reversedhell.net> <20040424184418.GA25917@pc5.i.0x5.de> In-Reply-To: <20040424184418.GA25917@pc5.i.0x5.de> X-Enigmail-Version: 0.83.3.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: FreeBSD's malloc problem ? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Apr 2004 18:58:36 -0000 Nicolas Rachinsky wrote: > * Anton Alin-Adrian [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