Skip to main content.
home | support | download

Back to List Archive

bug(?) in swish regex (fwd)

From: Roy Tennant <rtennant(at)not-real.library.berkeley.edu>
Date: Fri Apr 09 1999 - 22:24:18 GMT
This is now available in the Patches directory:

http://sunsite.berkeley.edu/SWISH-E/Patches/

Roy

---------- Forwarded message ----------
Date: Fri, 9 Apr 1999 13:42:01 -0700 (PDT)
From: Ron Klatchko <ron@library.ucsf.edu>
To: Multiple recipients of list <swish-e@sunsite.berkeley.edu>
Subject: [SWISH-E] bug(?) in swish regex

I'm forwarding this to list on behalf of Richard Beebe.  Please do not
include me in any responses.

>Date: Fri, 09 Apr 1999 11:26:19 -0400
>From: Rick Beebe <richard.beebe@yale.edu>
>Subject: bug(?) in swish regex
>Organization: Yale University School of Medicine
>
>I've had regular unexplained crashes in Swish 1.3.1 running under Digital
>Unix 4.0D. The crash is always a segmentation fault in matchARegex. After a
>bunch of experimentation (I haven't done anything with regex before) I added
>regfree calls to the routine and that fixed _most_ of the crashes. I'm not
>sure why it should make a difference--I would have thought re would be freed
>when leaving the routine--but it did. It still crashes occasionally--once
>every three or four days--but it never used to even make it through a night
>before.
>
>*** string.c	Fri Apr  9 11:13:34 1999
>--- string.c.orig	Fri Dec 11 13:33:31 1998
>***************
>*** 599,622 ****
>  /*---------------------------------------------------------*/
>  /* Match a regex and a string */
>  
>! int matchARegex( char *str, char *pattern)
>  {
>  	int  status;
>! 	regex_t	re;
>! 
>  	status = regcomp(&re, pattern, REG_EXTENDED);
>! 	if ( status != 0) {
>!       	regfree(&re);
>  		return 0;
>!   	}
>! 
>  	status = regexec(&re,str,(size_t)0,NULL,0);
>! 	if (status != 0) {
>!       	regfree(&re);
>  		return 0;
>!    	}
>! 
>!    	regfree(&re);
>  	return 1;
>  }
>  /*-----------------------------------------------------*/
>--- 599,617 ----
>  /*---------------------------------------------------------*/
>  /* Match a regex and a string */
>  
>! int matchARegex( char *str, char *pattern) 
>  {
>  	int  status;
>! 	regex_t re;
>! 	
>  	status = regcomp(&re, pattern, REG_EXTENDED);
>! 	if ( status != 0)
>  		return 0;
>! 	
>  	status = regexec(&re,str,(size_t)0,NULL,0);
>! 	if (status != 0)
>  		return 0;
>! 	
>  	return 1;
>  }
>  /*-----------------------------------------------------*/
>
>
>-- 
>  _______________________________________________________________________
>
>    Rick Beebe                                           (203) 785-6416
>    Manager, Systems & Network Engineering          FAX: (203) 785-3978
>    ITS-Med Client & Technology Services         Richard.Beebe@yale.edu   
>    Yale University School of Medicine                                 
>    P.O. Box 208078, New Haven, CT 06520-8078
>  _______________________________________________________________________
>
>
Received on Fri Apr 9 15:16:50 1999