aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-10-29 13:54:55 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-10-29 13:54:55 -0200
commitc6ef3e2672859a26bb5f0ab5fa3f99a3fb32d5b4 (patch)
tree8deefb422b4f9e6baa429c8b694d9deb6f2f5e4f
parentba8dca00ac1e88d7f083dfccf0badd0b6345e700 (diff)
downloadlua-c6ef3e2672859a26bb5f0ab5fa3f99a3fb32d5b4.tar.gz
lua-c6ef3e2672859a26bb5f0ab5fa3f99a3fb32d5b4.tar.bz2
lua-c6ef3e2672859a26bb5f0ab5fa3f99a3fb32d5b4.zip
bug: by-one error when creating short source names (luaO_chunkid)
-rw-r--r--lobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lobject.c b/lobject.c
index 0c61ac0f..b3bacc08 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 2.41 2010/10/28 15:39:03 roberto Exp roberto $ 2** $Id: lobject.c,v 2.42 2010/10/29 11:13:14 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -226,7 +226,7 @@ void luaO_chunkid (char *out, const char *source, size_t bufflen) {
226 else { /* string; format as [string "source"] */ 226 else { /* string; format as [string "source"] */
227 const char *nl = strchr(source, '\n'); /* find first new line (if any) */ 227 const char *nl = strchr(source, '\n'); /* find first new line (if any) */
228 addstr(out, PRE, LL(PRE)); /* add prefix */ 228 addstr(out, PRE, LL(PRE)); /* add prefix */
229 bufflen -= LL(PRE RETS POS); /* save space for prefix+suffix */ 229 bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */
230 if (l < bufflen && nl == NULL) { /* small one-line source? */ 230 if (l < bufflen && nl == NULL) { /* small one-line source? */
231 addstr(out, source, l); /* keep it */ 231 addstr(out, source, l); /* keep it */
232 } 232 }