Ejemplo n.º 1
0
void crm114__regfree(regex_t *preg)
{
  /* The following bug occurs in the 0.8.0 version of tre:

     When tre is configured to use the system regex interface, it
     #defines 'tre_regfree' to be 'regfree'.  This usually works fine,
     except in situations where 'regfree' has already been resolved by
     the linker to point to libc's version (e.g. when loaded from
     within the Python interpreter).  In this case, our use of
     'tre_regncomp' (which is not #defined away) initializes the regex
     context, but it is freed by libc's 'regfree', which causes a
     segfault.

     Luckily, we can still access libtre's 'tre_free' function to free
     up context state allocated by tre.
   */

  Dl_info info;
  memset(&info, 0, sizeof(info));
  if (dladdr((void *)tre_regfree, &info)) {
    if (info.dli_fname && strstr(info.dli_fname, "libtre") == NULL) {
      tre_free(preg);
      return;
    }
  }

  tre_regfree(preg);
}
Ejemplo n.º 2
0
void
tre_regfree(regex_t *preg)
{
  tre_free(preg);
}