commit c6ef3e2672859a26bb5f0ab5fa3f99a3fb32d5b4
parent ba8dca00ac1e88d7f083dfccf0badd0b6345e700
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 29 Oct 2010 13:54:31 -0200
bug: by-one error when creating short source names (luaO_chunkid)
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lobject.c b/lobject.c
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.c,v 2.41 2010/10/28 15:39:03 roberto Exp roberto $
+** $Id: lobject.c,v 2.42 2010/10/29 11:13:14 roberto Exp roberto $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
@@ -226,7 +226,7 @@ void luaO_chunkid (char *out, const char *source, size_t bufflen) {
else { /* string; format as [string "source"] */
const char *nl = strchr(source, '\n'); /* find first new line (if any) */
addstr(out, PRE, LL(PRE)); /* add prefix */
- bufflen -= LL(PRE RETS POS); /* save space for prefix+suffix */
+ bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */
if (l < bufflen && nl == NULL) { /* small one-line source? */
addstr(out, source, l); /* keep it */
}