From owner-freebsd-hackers@FreeBSD.ORG Wed Jul 6 20:46:48 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org 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 49E6B16A41C; Wed, 6 Jul 2005 20:46:48 +0000 (GMT) (envelope-from Maksim.Yevmenkin@savvis.net) Received: from mailgate1b.savvis.net (mailgate1b.savvis.net [216.91.182.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id F2E2B43D46; Wed, 6 Jul 2005 20:46:47 +0000 (GMT) (envelope-from Maksim.Yevmenkin@savvis.net) Received: from localhost (localhost.localdomain [127.0.0.1]) by mailgate1b.savvis.net (Postfix) with ESMTP id 330883BEF1; Wed, 6 Jul 2005 15:46:47 -0500 (CDT) Received: from mailgate1b.savvis.net ([127.0.0.1]) by localhost (mailgate1b.savvis.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 22519-02-32; Wed, 6 Jul 2005 15:46:47 -0500 (CDT) Received: from out001.email.savvis.net (out001.apptix.savvis.net [216.91.32.44]) by mailgate1b.savvis.net (Postfix) with ESMTP id 071223BE2A; Wed, 6 Jul 2005 15:46:47 -0500 (CDT) Received: from s228130hz1ew171.apptix-01.savvis.net ([10.146.4.29]) by out001.email.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Wed, 6 Jul 2005 15:46:44 -0500 Received: from [10.254.186.111] ([64.14.1.106]) by s228130hz1ew171.apptix-01.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Wed, 6 Jul 2005 15:46:42 -0500 Message-ID: <42CC4331.7080703@savvis.net> Date: Wed, 06 Jul 2005 13:46:41 -0700 From: Maksim Yevmenkin User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050404) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Giorgos Keramidas References: <20050706185536.GA4700@dice.seeling33.de> <42CC2C36.7090003@savvis.net> <20050706203924.GB6160@gothmog.gr> In-Reply-To: <20050706203924.GB6160@gothmog.gr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 06 Jul 2005 20:46:42.0937 (UTC) FILETIME=[D0FE5E90:01C5826B] X-Virus-Scanned: amavisd-new at savvis.net Cc: freebsd-hackers@freebsd.org, Stefan Sperling Subject: Re: bus error in strsep 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, 06 Jul 2005 20:46:48 -0000 >>>int main(int argc, char* argv[]) >>>{ >>> char *c = "whats:your:name:buddy?"; >> >> ^^^^^^^^^^^^^^^^ that is not read only copy. you can not write >>into it. replace it with >> >> char *c = strdup("whats:your:name:buddy?"); > > Or the following: > > char c[] = "whats:your:name:buddy?"; > > which doesn't require a free() operation when you're done with c[]. actually it still will crash :) beetle% cat 5.c #include int main(int argc, char* argv[]) { char c[] = "whats:your:name:buddy?"; strsep((char **) &c, ":"); return (0); } beetle% gcc -Wall -ggdb 5.c beetle% ./a.out Segmentation fault (core dumped) so something like this #include int main(int argc, char* argv[]) { char c[] = "whats:your:name:buddy?", *s = c; strsep((char **) &s, ":"); return (0); } will work too. max