Re: Strange segfault with improper usage

Paolo <[email protected]>
Newsgroups gmane.mail.spam.crm114
Message-ID <20080326220214.GR20978@localhost>
On Mon, Mar 24, 2008 at 05:00:53PM +0100, Paolo wrote:
...
> 
> The attached patch reworks the regex cache code quite a bit; it correctly

which must be modified a little:

 -    j = 0;
-+    i=j=0;
 +    if (internal_trace)
 +    {
 +      fprintf (stderr, "Checking the regex cache for '%s'\n", regex);
-+      for (j=0; j < CRM_REGEX_CACHESIZE; j++) {
++      for (i=0; i < CRM_REGEX_CACHESIZE; i++) {
 +       if (regex_cache[i].regex_len > 0) fprintf (stderr,
 +         "  regex[%d]:'%s' cf=%#x(%#x) len=%d(%d)\n",
 +         i,regex_cache[i].regex,regex_cache[i].cflags,cflags,
 +         regex_cache[i].regex_len,regex_len);
 +      }
  #ifdef REGEX_CACHE_LINEAR_SEARCH
 +      fputs (" [<- rex cache linear]\n", stderr);
 +    }
++    i=j=0;

else with -T on you'd likely get segv. It only matters while Tracing.
Pointed out by Gerrit.

The sample runs are correct, there were 2 such loops, reduced to 1 and moved 
up for final diff; but 1 used i while the other j and the merge didn't get it
right.

-- 
paolo

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.