From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14740 invoked by alias); 8 Aug 2017 11:07:08 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41513 Received: (qmail 7506 invoked by uid 1010); 8 Aug 2017 11:07:08 -0000 X-Qmail-Scanner-Diagnostics: from mx1.redhat.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.132.183.28):SA:0(-5.0/5.0):. Processed in 4.802911 secs); 08 Aug 2017 11:07:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: kdudka@redhat.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 57DFE61487 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kdudka@redhat.com From: Kamil Dudka To: Peter Stephenson Cc: zsh-workers@zsh.org Subject: Re: shwordsplit: final non-whitespace IFS character problem Date: Tue, 08 Aug 2017 12:56:40 +0200 Message-ID: <5431781.suoAVAckmf@kdudka-nb> User-Agent: KMail/4.14.10 (Linux/4.9.34-gentoo; KDE/4.14.32; x86_64; ; ) In-Reply-To: <20170806210110.2328c3a2@ntlworld.com> References: <0f71b764-cc3d-5274-a16a-498b792bff6e@inlv.org> <20170806190834.5073e18a@ntlworld.com> <20170806210110.2328c3a2@ntlworld.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 08 Aug 2017 10:56:35 +0000 (UTC) On Sunday, August 06, 2017 21:01:10 Peter Stephenson wrote: > @@ -3545,6 +3546,21 @@ spacesplit(char *s, int allownull, int heap, int quote) } > if (!allownull && t != s) > *ptr++ = dup(""); > + if (isset(POSIXSTRINGS) && ptr != eptr + 1) { > + /* > + * Trailing separators do not generate extra fields in POSIX. > + * Note this is only the final separator --- if the > + * immediately preceding field was null it is still counted. > + * So just back up one. > + */ > + --ptr; > + if (!heap) { > + char **ret2 = realloc(ret, sizeof(*ret) * (ptr+1-ret)); > + ptr -= ret-ret2; > + free(ret); > + ret = ret2; > + } > + } > *ptr = NULL; > return ret; > } Is it correct when you free() the pointer that you previously gave to realloc()? Could not it cause a double free()? Kamil