diff options
author | drh <drh@noemail.net> | 2013-07-18 14:16:48 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-07-18 14:16:48 +0000 |
commit | b8c068329d996dc86787d2407c9237847ca82cb3 (patch) | |
tree | 44c6155664a1a0546a19ee53842e8bd1f1576b41 /ext/misc/regexp.c | |
parent | 47af6e76d6d815da8d31aaa05ac014fe29076293 (diff) | |
download | sqlite-b8c068329d996dc86787d2407c9237847ca82cb3.tar.gz sqlite-b8c068329d996dc86787d2407c9237847ca82cb3.zip |
Documentation changes to warn that sqlite3_set_auxdata() might call the
destructor even before it returns. Also fix the regexp extension to deal
with that case. Ticket [406d3b2ef91c].
FossilOrigin-Name: 7acc8cd32d593a473c9e9adaf323220a7a46480a
Diffstat (limited to 'ext/misc/regexp.c')
-rw-r--r-- | ext/misc/regexp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/misc/regexp.c b/ext/misc/regexp.c index 16fa7d0b9..7244d5299 100644 --- a/ext/misc/regexp.c +++ b/ext/misc/regexp.c @@ -713,6 +713,7 @@ static void re_sql_func( const char *zPattern; /* The regular expression */ const unsigned char *zStr;/* String being searched */ const char *zErr; /* Compile error message */ + int setAux = 0; /* True to invoke sqlite3_set_auxdata() */ pRe = sqlite3_get_auxdata(context, 0); if( pRe==0 ){ @@ -728,12 +729,15 @@ static void re_sql_func( sqlite3_result_error_nomem(context); return; } - sqlite3_set_auxdata(context, 0, pRe, (void(*)(void*))re_free); + setAux = 1; } zStr = (const unsigned char*)sqlite3_value_text(argv[1]); if( zStr!=0 ){ sqlite3_result_int(context, re_match(pRe, zStr, -1)); } + if( setAux ){ + sqlite3_set_auxdata(context, 0, pRe, (void(*)(void*))re_free); + } } /* |