aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-01-28 10:59:13 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-01-28 10:59:13 -0200
commit64205e91a36217ec73d77274ca44716091b25efd (patch)
tree36eff5bdc9adad7537abaf4ce8b46bb1309028a8
parent81736885429eb660aa39a210ef1ecddf347e001d (diff)
downloadlua-64205e91a36217ec73d77274ca44716091b25efd.tar.gz
lua-64205e91a36217ec73d77274ca44716091b25efd.tar.bz2
lua-64205e91a36217ec73d77274ca44716091b25efd.zip
empty string may cause out-of-bound access
-rw-r--r--liolib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/liolib.c b/liolib.c
index f55f7a63..594bbebf 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 2.70 2005/12/29 15:32:11 roberto Exp roberto $ 2** $Id: liolib.c,v 2.71 2006/01/17 13:54:02 roberto Exp roberto $
3** Standard I/O (and system) library 3** Standard I/O (and system) library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -283,7 +283,7 @@ static int read_line (lua_State *L, FILE *f) {
283 return (lua_strlen(L, -1) > 0); /* check whether read something */ 283 return (lua_strlen(L, -1) > 0); /* check whether read something */
284 } 284 }
285 l = strlen(p); 285 l = strlen(p);
286 if (p[l-1] != '\n') 286 if (l == 0 || p[l-1] != '\n')
287 luaL_addsize(&b, l); 287 luaL_addsize(&b, l);
288 else { 288 else {
289 luaL_addsize(&b, l - 1); /* do not include `eol' */ 289 luaL_addsize(&b, l - 1); /* do not include `eol' */