Date: Fri, 2 Sep 2011 21:53:35 +0400 From: Andrey Chernov <ache@FreeBSD.ORG> To: Gabor Kovesdan <gabor@FreeBSD.ORG> Cc: src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG Subject: Re: svn commit: r225336 - user/gabor/grep/trunk/regex Message-ID: <20110902175335.GA27989@vniz.net> In-Reply-To: <201109021650.p82GoOtJ007597@svn.freebsd.org> References: <201109021650.p82GoOtJ007597@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110902175335.GA27989>