From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from scc-mailout.scc.kit.edu (scc-mailout.scc.kit.edu [129.13.185.202]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p2C0RiP3017733 for ; Fri, 11 Mar 2011 19:27:45 -0500 (EST) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by scc-mailout-02.scc.kit.edu with esmtp (Exim 4.72 #1) id 1PyCgF-0007oC-7T; Sat, 12 Mar 2011 01:27:42 +0100 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1PyCgF-00057N-67 for discuss@mdocml.bsd.lv; Sat, 12 Mar 2011 01:27:39 +0100 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.69) (envelope-from ) id 1PyCgF-0002rP-5B for discuss@mdocml.bsd.lv; Sat, 12 Mar 2011 01:27:39 +0100 Received: from schwarze by usta.de with local (Exim 4.72) (envelope-from ) id 1PyCgE-0003ne-Pr for discuss@mdocml.bsd.lv; Sat, 12 Mar 2011 01:27:38 +0100 Date: Sat, 12 Mar 2011 01:27:38 +0100 From: Ingo Schwarze To: discuss@mdocml.bsd.lv Subject: Re: Logic error in mandoc.c time2a() Message-ID: <20110312002738.GA12289@iris.usta.de> References: <20110311204204.GA85668@acme.spoerlein.net> X-Mailinglist: mdocml-discuss Reply-To: discuss@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110311204204.GA85668@acme.spoerlein.net> User-Agent: Mutt/1.5.21 (2010-09-15) Hi Ulrich, Ulrich Spoerlein wrote on Fri, Mar 11, 2011 at 09:42:04PM +0100: > now that the clang/llvm folks unbroke their static analysis tool again, > I had another run on the mdocml sources. Only one bug stood out > (disregard the 'Dead store' class). > > See https://www.spoerlein.net/scan-build/mdocml/2011-03-11-1/ > > In time2a(), 'buf' is a stack-local buffer and its address will be > returned. Oops. Oops indeed, i guess i'm programming too much in Perl lately, forming bad habits like returning references to local storage. > Either make it global, static, use malloc/free, malloc is the way to go here; time2a ist static and called from one place only, and the return value is strdup'ed right away, so we can as well malloc it in the first place. I need to cook a diff... > or have the caller provide the buffer, not sure which solution you guys > would prefer. Thanks, Ingo -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv