** Compute new size for buffer 'B', enough to accommodate extra 'sz' ** bytes. (The test for "not big enough" also gets the case when the ** computation of 'newsize' overflows.) */
| 533 | ** computation of 'newsize' overflows.) |
| 534 | */ |
| 535 | static size_t newbuffsize (luaL_Buffer *B, size_t sz) { |
| 536 | size_t newsize = (B->size / 2) * 3; /* buffer size * 1.5 */ |
| 537 | if (l_unlikely(MAX_SIZET - sz < B->n)) /* overflow in (B->n + sz)? */ |
| 538 | return luaL_error(B->L, "buffer too large"); |
| 539 | if (newsize < B->n + sz) /* not big enough? */ |
| 540 | newsize = B->n + sz; |
| 541 | return newsize; |
| 542 | } |
| 543 | |
| 544 | |
| 545 | /* |
no test coverage detected