[Gambas-devel] 1.9.1 pcre problem diagnosed

Benoit Minisini gambas at ...1...
Wed Jan 12 15:25:28 CET 2005


On Wednesday 12 January 2005 14:56, Rob wrote:
> On Wednesday 12 January 2005 05:01, Benoit Minisini wrote:
> > On Tuesday 11 January 2005 19:09, Rob wrote:
> > > One of the last changes I made to the regexp.c file was
> > > adding exec options and compile options as optional
> > > arguments. Unfortunately, if you don't specify both
> >
> > Be careful, Rob!
> > GB.ToZeroString() returns a -temporary- string that is freed
> > later by the interpreter. Don't use it if you want to store a
> > string into an object structure! Use GB.NewString() instead,
> > and GB.FreeString() to free it.
>
> Well, the compiler and exec options are both integers (sums of
> flags) so I assume this will not be an issue.
>
> Rob
>

I'm talking about this code:

----8<-----------------------------------------------------------------

BEGIN_METHOD(CREGEXP_new, GB_STRING subject; GB_STRING pattern; GB_INTEGER 
coptions; GB_INTEGER eoptions)

     int errptr;
     const char *errstr;
     int *ovector;
     pcre *code;
     int copts;
     int eopts;

// BEGIN source of random crashes

     THIS->subject = GB.ToZeroString(ARG(subject));
     /* Benoit, the reason we need to keep the subject string around 
	is because pcre returns each match using an offset into the 
	original subject and a length, not as a string! -RK */

     THIS->pattern = GB.ToZeroString(ARG(pattern));

// END source of random crashes

----8<-----------------------------------------------------------------

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the Devel mailing list