From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8643 invoked by alias); 13 Nov 2013 08:16:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 8630 invoked by uid 89); 13 Nov 2013 08:16:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_40,RDNS_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Nov 2013 08:16:21 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAD8GDpa027614 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 13 Nov 2013 03:16:13 -0500 Received: from tucnak.zalov.cz (vpn1-5-98.ams2.redhat.com [10.36.5.98]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rAD8GBxh021748 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Nov 2013 03:16:13 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.7/8.14.7) with ESMTP id rAD8GBH3015944; Wed, 13 Nov 2013 09:16:11 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.7/8.14.7/Submit) id rAD8GAM8015943; Wed, 13 Nov 2013 09:16:10 +0100 Date: Wed, 13 Nov 2013 09:51:00 -0000 From: Jakub Jelinek To: Dodji Seketeli Cc: GCC Patches , Tom Tromey , Manuel =?iso-8859-1?B?TPNwZXotSWLh8WV6?= , Bernd Edlinger Subject: Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals Message-ID: <20131113081610.GH27813@tucnak.zalov.cz> Reply-To: Jakub Jelinek References: <20131031144309.GR27813@tucnak.zalov.cz> <87y559xz7y.fsf@redhat.com> <20131031173649.GW27813@tucnak.zalov.cz> <87zjpbb5qu.fsf@redhat.com> <20131111142159.GZ27813@tucnak.zalov.cz> <878uwuap4f.fsf@redhat.com> <878uwt63e2.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878uwt63e2.fsf@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg01408.txt.bz2 On Tue, Nov 12, 2013 at 04:33:41PM +0100, Dodji Seketeli wrote: > + > + memmove (*line, l, len); > + (*line)[len - 1] = '\0'; > + *line_len = --len; Shouldn't this be testing that len > 0 && (*line)[len - 1] == '\n' first before you decide to overwrite it and decrement len? Though in that case there would be no '\0' termination of the string for files not ending in a new-line. So, either get_next_line should append '\n' to the buffer, or you should have there space for that, or you can't rely on zero termination of the string and need to use just the length. Jakub