[TRE-general] Strange regcomp memory problems

Seb Martin gee.sucka.foo.spam at gmail.com
Mon Feb 26 20:23:26 EET 2007


It seems like regcomp() is writing outside its memory space.  Here is my
code:

#include <stdio.h>
#include <tre/regex.h>

int main() {
        int a=1;
        regex_t reComp;
        int b=2;

        printf("Size of regex_t : %d\n", sizeof(regex_t));
        printf("Before regcomp() : %d, %d\n", a, b);
        regcomp(&reComp, "abc", REG_ICASE|REG_EXTENDED);
        printf("After regcomp() : %d, %d\n", a, b);
}

.. and the output:

# ./test
Size of regex_t : 8
Before regcomp() : 1, 2
After regcomp() : 140, 4436732
Segmentation fault

Is there a way to find out if I'm declaring the correct regex_t ?  I posted
the size of the struct in the output (8).  Is this correct?  Am I missing
something?  The only thing that I can think of is that I am declaring a gnu
regex_t .  That, or there is a severe memory issue with regcomp().  Can
someone else compile this simple little program and see if they get the same
result?  What I posted is the entire content of my test.c file it is
compiled with gcc 4.0.2.  I am using TRE 0.7.5.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://laurikari.net/pipermail/tre-general/attachments/20070226/4ee26439/attachment.html 


More information about the TRE-general mailing list