diff options
Diffstat (limited to '')
-rw-r--r-- | lauxlib.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -94,14 +94,14 @@ static int pushglobalfuncname (lua_State *L, lua_Debug *ar) { | |||
94 | 94 | ||
95 | 95 | ||
96 | static void pushfuncname (lua_State *L, lua_Debug *ar) { | 96 | static void pushfuncname (lua_State *L, lua_Debug *ar) { |
97 | if (pushglobalfuncname(L, ar)) { /* try first a global name */ | 97 | if (*ar->namewhat != '\0') /* is there a name from code? */ |
98 | lua_pushfstring(L, "function '%s'", lua_tostring(L, -1)); | ||
99 | lua_remove(L, -2); /* remove name */ | ||
100 | } | ||
101 | else if (*ar->namewhat != '\0') /* is there a name from code? */ | ||
102 | lua_pushfstring(L, "%s '%s'", ar->namewhat, ar->name); /* use it */ | 98 | lua_pushfstring(L, "%s '%s'", ar->namewhat, ar->name); /* use it */ |
103 | else if (*ar->what == 'm') /* main? */ | 99 | else if (*ar->what == 'm') /* main? */ |
104 | lua_pushliteral(L, "main chunk"); | 100 | lua_pushliteral(L, "main chunk"); |
101 | else if (pushglobalfuncname(L, ar)) { /* try a global name */ | ||
102 | lua_pushfstring(L, "function '%s'", lua_tostring(L, -1)); | ||
103 | lua_remove(L, -2); /* remove name */ | ||
104 | } | ||
105 | else if (*ar->what != 'C') /* for Lua functions, use <file:line> */ | 105 | else if (*ar->what != 'C') /* for Lua functions, use <file:line> */ |
106 | lua_pushfstring(L, "function <%s:%d>", ar->short_src, ar->linedefined); | 106 | lua_pushfstring(L, "function <%s:%d>", ar->short_src, ar->linedefined); |
107 | else /* nothing left... */ | 107 | else /* nothing left... */ |
@@ -541,17 +541,17 @@ static void newbox (lua_State *L) { | |||
541 | 541 | ||
542 | /* | 542 | /* |
543 | ** Compute new size for buffer 'B', enough to accommodate extra 'sz' | 543 | ** Compute new size for buffer 'B', enough to accommodate extra 'sz' |
544 | ** bytes plus one for a terminating zero. (The test for "not big enough" | 544 | ** bytes plus one for a terminating zero. |
545 | ** also gets the case when the computation of 'newsize' overflows.) | ||
546 | */ | 545 | */ |
547 | static size_t newbuffsize (luaL_Buffer *B, size_t sz) { | 546 | static size_t newbuffsize (luaL_Buffer *B, size_t sz) { |
548 | size_t newsize = (B->size / 2) * 3; /* buffer size * 1.5 */ | 547 | size_t newsize = B->size; |
549 | if (l_unlikely(sz > MAX_SIZE - B->n - 1)) | 548 | if (l_unlikely(sz >= MAX_SIZE - B->n)) |
550 | return cast_sizet(luaL_error(B->L, "resulting string too large")); | 549 | return cast_sizet(luaL_error(B->L, "resulting string too large")); |
551 | if (newsize < B->n + sz + 1 || newsize > MAX_SIZE) { | 550 | /* else B->n + sz + 1 <= MAX_SIZE */ |
552 | /* newsize was not big enough or too big */ | 551 | if (newsize <= MAX_SIZE/3 * 2) /* no overflow? */ |
552 | newsize += (newsize >> 1); /* new size *= 1.5 */ | ||
553 | if (newsize < B->n + sz + 1) /* not big enough? */ | ||
553 | newsize = B->n + sz + 1; | 554 | newsize = B->n + sz + 1; |
554 | } | ||
555 | return newsize; | 555 | return newsize; |
556 | } | 556 | } |
557 | 557 | ||