Fix a memory leak in nse_pcrelib.cc. A string was being copied with

strdup before being handed to lua_pushstring. That was excessive because
lua_pushstring already makes its own internal copy of the string. This
was found by Coverity.
This commit is contained in:
david 2009-07-23 02:59:57 +00:00
parent f673eff211
commit e801b1b341

View file

@ -183,7 +183,7 @@ static void Lpcre_push_substrings (lua_State *L, const char *text, pcre2 *ud)
unsigned int n = (tabptr[0] << 8) | tabptr[1]; /* number of the capturing parenthesis */
if (n > 0 && n <= (unsigned) ud->ncapt) { /* check range */
unsigned int j = n * 2;
lua_pushstring(L, strdup((char*)tabptr + 2)); /* name of the capture, zero terminated */
lua_pushstring(L, (char*)tabptr + 2); /* name of the capture, zero terminated */
if (match[j] >= 0)
lua_pushlstring(L, text + match[j], match[j + 1] - match[j]);
else