From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 17:53:38 2011 Return-Path: Delivered-To: svn-src-user@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9271C106564A; Fri, 2 Sep 2011 17:53:38 +0000 (UTC) (envelope-from ache@vniz.net) Received: from vniz.net (vniz.net [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 14DA48FC19; Fri, 2 Sep 2011 17:53:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vniz.net (8.14.5/8.14.5) with ESMTP id p82HravN028058; Fri, 2 Sep 2011 21:53:36 +0400 (MSK) (envelope-from ache@vniz.net) Received: (from ache@localhost) by localhost (8.14.5/8.14.5/Submit) id p82HranI028057; Fri, 2 Sep 2011 21:53:36 +0400 (MSK) (envelope-from ache) Date: Fri, 2 Sep 2011 21:53:35 +0400 From: Andrey Chernov To: Gabor Kovesdan Message-ID: <20110902175335.GA27989@vniz.net> Mail-Followup-To: Andrey Chernov , Gabor Kovesdan , src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG References: <201109021650.p82GoOtJ007597@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201109021650.p82GoOtJ007597@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG Subject: Re: svn commit: r225336 - user/gabor/grep/trunk/regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 17:53:38 -0000 On Fri, Sep 02, 2011 at 04:50:24PM +0000, Gabor Kovesdan wrote: > - Do not cast to unsigned char because it can cause a segfault > - fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; \ > + fg->qsBc[fg->pattern[i]] = fg->len - i; \ > - fg->qsBc[(unsigned)c] = fg->len - i; \ > + fg->qsBc[c] = fg->len - i; \ I see there was cast to (unsigned) not to (unsigned char). They works in very different ways. To be safe: never cast char to (unsigned), only to (unsigned char). If 8bit is set in the character, i.e. it is negative, cast to (unsigned) provides very big values because it promotes to (int) first and then makes (unsigned) from that (int). -- http://ache.vniz.net/