commit a84bca67fcf74241570d7f6d51243aecce9e71a6
parent 4ccfb2f9bc1db4457f27a63997d869e995292cc6
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Tue, 10 Nov 1998 17:37:51 -0200
bug: gsub/strfind do not check whether captures are properly finished.
Diffstat:
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/bugs b/bugs
@@ -48,3 +48,7 @@ Mon May 18 19:20:00 EST 1998
Mon Sep 7 15:57:02 EST 1998
>> function "luaL_argerror" prints wrong argument number (from a user's point
of view) when functions have upvalues.
+
+** lstrlib.c
+Tue Nov 10 17:29:36 EDT 1998
+>> gsub/strfind do not check whether captures are properly finished.
diff --git a/lstrlib.c b/lstrlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstrlib.c,v 1.18 1998/07/01 14:21:57 roberto Exp roberto $
+** $Id: lstrlib.c,v 1.19 1998/07/12 16:13:45 roberto Exp roberto $
** Standard library for strings and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -138,8 +138,11 @@ struct Capture {
static void push_captures (struct Capture *cap)
{
int i;
- for (i=0; i<cap->level; i++)
- lua_pushlstring(cap->capture[i].init, cap->capture[i].len);
+ for (i=0; i<cap->level; i++) {
+ int l = cap->capture[i].len;
+ if (l == -1) lua_error("unfinished capture");
+ lua_pushlstring(cap->capture[i].init, l);
+ }
}