From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 23 16:43:54 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 9C1BB1065680 for ; Wed, 23 Apr 2008 16:43:54 +0000 (UTC) (envelope-from mwm@mired.org) Received: from mired.org (student.mired.org [66.92.153.77]) by mx1.freebsd.org (Postfix) with ESMTP id 137F18FC1A for ; Wed, 23 Apr 2008 16:43:53 +0000 (UTC) (envelope-from mwm@mired.org) Received: (qmail 54751 invoked from network); 23 Apr 2008 12:42:33 -0400 Received: from unknown (HELO mbook-fbsd) (192.168.195.251) by 0 with SMTP; 23 Apr 2008 12:42:33 -0400 Date: Wed, 23 Apr 2008 12:43:51 -0400 From: Mike Meyer To: Roman Divacky Message-ID: <20080423124351.426627d3@mbook-fbsd> In-Reply-To: <20080423162635.GA42593@freebsd.org> References: <7d6fde3d0804222240j6b42b77yd86d8accb5a959fa@mail.gmail.com> <20080423025048.6b51a580@bhuda.mired.org> <5F412E73-29FC-4876-A6F0-9BC269876192@bitpowder.com> <20080423113951.020f0130@mbook-fbsd> <20080423162635.GA42593@freebsd.org> Organization: Meyer Consulting X-Mailer: Claws Mail 3.0.2 (GTK+ 2.12.5; amd64-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Wed, 23 Apr 2008 17:44:09 +0000 Cc: Mike Meyer , Garrett Cooper , 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 16:43:54 -0000 On Wed, 23 Apr 2008 18:26:35 +0200 Roman Divacky wrote: > > I think someone gave the reason I'm about to: trying to copy a NULL > > pointer means I have a bug somewhere earlier in my code that will > > eventually produce visibly wrong results - a segfault being such. The > > sooner that happens after the bug, the less code I have to search to > > find it, the better for me. > > if only the fix was something else than > > if (ptr != NULL) > strdup(ptr); > > :) Again, under what conditions would this "fix" be considered correct? I.e. - when does it make sense to try and duplicate a string that isn't? http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information.