From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 23 22:12:36 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E5EE1065675 for ; Wed, 23 Apr 2008 22:12:36 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id CD4688FC0A for ; Wed, 23 Apr 2008 22:12:35 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (adsl23-13.kln.forthnet.gr [77.49.150.13]) (authenticated bits=128) by igloo.linux.gr (8.14.2/8.14.2/Debian-3) with ESMTP id m3NMCEAn021621 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 24 Apr 2008 01:12:24 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id m3NMCEul002340; Thu, 24 Apr 2008 01:12:14 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id m3NMC9eW002339; Thu, 24 Apr 2008 01:12:10 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: Simun Mikecin References: <293918.47889.qm@web36608.mail.mud.yahoo.com> Date: Thu, 24 Apr 2008 01:12:09 +0300 In-Reply-To: <293918.47889.qm@web36608.mail.mud.yahoo.com> (Simun Mikecin's message of "Wed, 23 Apr 2008 09:06:44 -0700 (PDT)") Message-ID: <87d4og9q6e.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-MailScanner-ID: m3NMCEAn021621 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.908, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.49, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: hackers@freebsd.org Subject: Re: strdup(NULL) supposed to create SIGSEGV? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Apr 2008 22:12:36 -0000 On Wed, 23 Apr 2008 09:06:44 -0700 (PDT), Simun Mikecin wrote: >>If you're going to quote documents to support your ideas, it's probably >>better to read them first. > > My apologies. My fingers were faster than my mind. But this made me > read it the way I should have done in the first place. And I see that > it says: > > "A null pointer is returned if the new string cannot be created." > > Does that also mean that a null pointer is returned if the input is a > NULL pointer (cause in that case new string could not be created)? No. It means that if the input is *valid* but the is a problem with completing the operation of strdup(validstring), then an error is returned to let you know something bad is going on.