From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26927 invoked from network); 16 Mar 2004 15:20:12 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 16 Mar 2004 15:20:12 -0000 Received: (qmail 4995 invoked by alias); 16 Mar 2004 15:20:07 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19631 Received: (qmail 4919 invoked from network); 16 Mar 2004 15:20:07 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 16 Mar 2004 15:20:07 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [216.254.112.45] by sunsite.dk (MessageWall 1.0.8) with SMTP; 16 Mar 2004 15:20:6 -0000 Received: by acolyte.scowler.net (Postfix, from userid 1000) id 1E3017004A; Tue, 16 Mar 2004 10:20:06 -0500 (EST) Date: Tue, 16 Mar 2004 10:20:06 -0500 From: Clint Adams To: zsh-workers@sunsite.dk, Matthias Kopfermann Subject: Re: (Fwd) segfault with pcre_study alone Message-ID: <20040316152006.GA21815@scowler.net> References: <1040316145551.ZM8418@candle.brasslantern.com> <20040316150753.GA21121@scowler.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040316150753.GA21121@scowler.net> User-Agent: Mutt/1.5.5.1+cvs20040105i > The shell should return an error instead of segfaulting if pcre_study is > called before pcre_compile. Index: Doc/Zsh/mod_pcre.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_pcre.yo,v retrieving revision 1.3 diff -u -r1.3 mod_pcre.yo --- Doc/Zsh/mod_pcre.yo 4 Jul 2001 15:13:33 -0000 1.3 +++ Doc/Zsh/mod_pcre.yo 16 Mar 2004 15:10:20 -0000 @@ -8,6 +8,13 @@ findex(pcre_compile) item(tt(pcre_compile) [ tt(-aimx) ] var(PCRE))( Compiles a perl-compatible regular expression. + +Option tt(-a) will force the pattern to be anchored. +Option tt(-i) will compile a case-insensitive pattern. +Option tt(-m) will compile a multi-line pattern; that is, +tt(^) and tt($) will match newlines within the pattern. +Option tt(-x) will compile an extended pattern, wherein +whitespace and tt(#) comments are ignored. ) findex(pcre_study) item(tt(pcre_study))( Index: Src/Modules/pcre.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/pcre.c,v retrieving revision 1.5 diff -u -r1.5 pcre.c --- Src/Modules/pcre.c 27 Aug 2002 21:10:34 -0000 1.5 +++ Src/Modules/pcre.c 16 Mar 2004 15:10:20 -0000 @@ -3,7 +3,7 @@ * * This file is part of zsh, the Z shell. * - * Copyright (c) 2001 Clint Adams + * Copyright (c) 2001, 2002, 2003, 2004 Clint Adams * All rights reserved. * * Permission is hereby granted, without written agreement and without @@ -71,6 +71,13 @@ bin_pcre_study(char *nam, char **args, Options ops, int func) { const char *pcre_error; + + if (pcre_pattern == NULL) + { + zwarnnam(nam, "no pattern has been compiled for study: %s", + pcre_error, 0); + return 1; + } pcre_hints = pcre_study(pcre_pattern, 0, &pcre_error); if (pcre_error != NULL)