diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-10-29 13:54:55 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-10-29 13:54:55 -0200 |
| commit | c6ef3e2672859a26bb5f0ab5fa3f99a3fb32d5b4 (patch) | |
| tree | 8deefb422b4f9e6baa429c8b694d9deb6f2f5e4f | |
| parent | ba8dca00ac1e88d7f083dfccf0badd0b6345e700 (diff) | |
| download | lua-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.c | 4 |
1 files changed, 2 insertions, 2 deletions
| @@ -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 | } |
