From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12876 invoked from network); 13 May 2007 19:58:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.0 (2007-05-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=no version=3.2.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 May 2007 19:58:44 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 13662 invoked from network); 13 May 2007 19:58:38 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 May 2007 19:58:38 -0000 Received: (qmail 25198 invoked by alias); 13 May 2007 19:58:32 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23435 Received: (qmail 25188 invoked from network); 13 May 2007 19:58:32 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 13 May 2007 19:58:32 -0000 Received: (qmail 12932 invoked from network); 13 May 2007 19:58:32 -0000 Received: from nz-out-0506.google.com (64.233.162.236) by a.mx.sunsite.dk with SMTP; 13 May 2007 19:58:28 -0000 Received: by nz-out-0506.google.com with SMTP id o1so1598985nzf for ; Sun, 13 May 2007 12:58:27 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=WPGjeO/mCY0zlTkKRn7zIP3OxabqdnxgYZhBv5X/qi7epIzENEWeHRFyvTs8YwFkhDfcVk+xGOtnse+w6mDenffI1D4/PW+bh4pblGVG0aM8s3+xDGTjAoJHUBSsEYbRgJZHcVmyIcmITkmyUsBvwBjeKjVD4BhWAZZl7Jjywc0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=qfZRM14BRfMzYYXTqMy/thV6cvEmzL29398PyRNlklaT4PhfN5UB9uqkhipboxv2f+p2SDExPXoBOCVDxvHTW9wkWAAIGaVntuJOHfn0K1+tz8xw4InHd0T6ZsZzHRYynWEmnqSt77hJwMA9B6JWaZHjleEz57ltK6QHHl8cH6E= Received: by 10.115.54.1 with SMTP id g1mr706030wak.1179086306997; Sun, 13 May 2007 12:58:26 -0700 (PDT) Received: by 10.114.196.16 with HTTP; Sun, 13 May 2007 12:58:26 -0700 (PDT) Message-ID: Date: Sun, 13 May 2007 21:58:26 +0200 From: "Nikolai Weibull" Sender: nikolai.weibull@gmail.com To: "Zsh hackers list" Subject: [Patch] Bug in strmetasort() MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: 848aa32676f9e1b4 The old test for determining when s has reached the end of src was bugged. I don't quite see how this hasn't happened earlier, but I managed to catch it when running history-beginning-search-menu on an empty buffer. The solution is simple, store the end before starting the loop and then just verify that s stays below that end for the duration of the loop. This will be faster too, so it's a win-win-win situation. nikolai Index: sort.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/sort.c,v retrieving revision 1.5 diff -u -r1.5 sort.c --- sort.c 16 Apr 2007 13:21:26 -0000 1.5 +++ sort.c 13 May 2007 19:56:22 -0000 @@ -338,8 +338,9 @@ src = dst; } if (sortwhat & SORTIT_IGNORING_BACKSLASHES) { + char *end = src + len + 1; /* copy null byte, so increment length */ - for (s = src, t = dst; s - src != len+1; ) { + for (s = src, t = dst; s < end; ) { if (*s == '\\') { s++; len--;