aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Fix in string.repHEADmasterRoberto Ierusalimschy2025-07-231-8/+12
| | | | | | | | | | | | The cast of n (number of repetitions) to size_t may truncate its value, causing a buffer overflow later. Better to check the buffer size using lua_Integer, as all string lengths must fit in a lua_Integer and n already is a lua_Integer. If everything fits in MAX_SIZE, then we can safely convert n to size_t and compute the buffer size as a size_t. As a corner case, n can be larger than size_t if the strings being repeated have length zero, but in this case it will be multiplied by zero, so an overflow in the cast is irrelevant.
* Randomness added to table length computationRoberto Ierusalimschy2025-07-186-23/+48
| | | | | | | A bad actor could fill only a few entries in a table (power of twos in decreasing order, see tests) and produce a small table with a huge length. If your program builds a table with external data and iterates over its length, this behavior could be an issue.
* Correction in utf8.offsetRoberto Ierusalimschy2025-07-182-3/+13
| | | | Wrong utf-8 character may have no continuation bytes.
* Short strings can be external, tooRoberto Ierusalimschy2025-07-159-120/+168
| | | | | | | That complicates a little object equality (and therefore table access for long strings), but the old behavior was somewhat weird. (Short strings, a concept otherwise absent from the manual, could not be external.)
* lua.c doesn't use function pointers with LUA_READLINERoberto Ierusalimschy2025-07-091-22/+25
| | | | | Bugs in macOS prevent assigning 'add_history' to 'l_addhist' without a warning.
* New method to unload DLLsRoberto Ierusalimschy2025-07-093-36/+98
| | | | | | | | | | External strings created by DLLs may need the DLL code to be deallocated. This implies that a DLL can only be unloaded after all its strings were deallocated, which happen only after the run of all finalizers. To ensure that order, we create a 'library string' to represent each DLL and keep it locked. When this string is deallocated (after the deallocation of any string created by the DLL) it closes its corresponding DLL.
* lua option '--' may not be followed by scriptRoberto Ierusalimschy2025-07-082-5/+7
|
* Optional initialization for global declarationsRoberto Ierusalimschy2025-07-087-38/+96
|
* Correction in definition of CIST_FRESHRoberto Ierusalimschy2025-07-071-2/+2
| | | | | The cast must be made before the shift. If int has 16 bits, the shift would zero the value and the cast would cast 0 to 0.
* Details (comments)Roberto Ierusalimschy2025-07-075-8/+8
|
* Added missing casts from lua_Unsigned to size_tRoberto Ierusalimschy2025-07-012-3/+3
| | | | size_t can be smaller than lua_Usigned.
* LUAI_MAXSTACK defined privatelyRoberto Ierusalimschy2025-07-014-18/+17
| | | | | | LUAI_MAXSTACK is limited to INT_MAX/2, so can use INT_MAX/2 to define pseudo-indices (LUA_REGISTRYINDEX) in 'lua.h'. A change in the maximum stack size does not need to change the Lua-C ABI.
* Warning in loslib.c (signed-unsigned comparison)Roberto Ierusalimschy2025-06-271-2/+3
|
* Manual updated to version 5.5Roberto Ierusalimschy2025-06-272-9/+9
|
* Cast added to 'add_history'Roberto Ierusalimschy2025-06-261-2/+2
| | | | | MacOS defines 'add_history' with a "wrong" type (it returns 'int' instead of 'void').
* Application name for 'readline' is "lua", not "Lua"=listRoberto Ierusalimschy2025-06-231-1/+1
|
* Refactoring in the use of 'readline' by 'lua.c'Roberto Ierusalimschy2025-06-231-33/+38
| | | | | More common code for 'readline' loaded statically or dynamically (or not loaded).
* No need to limit variable declarations to 250Roberto Ierusalimschy2025-06-184-11/+38
| | | | Only local variables, which use registers, need this low limit.
* Check string indices when loading binary chunkRoberto Ierusalimschy2025-06-172-13/+11
| | | | | Lua is not religious about that, but it tries to avoid crashes when loading binary chunks.
* New metatable in an all-weak table can fool the GCRoberto Ierusalimschy2025-06-162-2/+15
| | | | | | All-weak tables are not being revisited after being visited during propagation; if it gets a new metatable after that, the new metatable may not be marked.
* Simpler code for 'traversetable'Roberto Ierusalimschy2025-06-162-13/+31
| | | | | Check the mode in a separate function (getmode), instead of using comma expressions inside the 'if' condition.
* Dump uses varints also for integer constantsRoberto Ierusalimschy2025-06-133-18/+48
| | | | | | Unlike sizes, these constants can be negative, so it encodes those integers into unsigned integers in a way that keeps small numbers small.
* The main thread cannot be closedRoberto Ierusalimschy2025-06-133-2/+10
| | | | | | No thread started with pcall (instead of resume) can be closed, because coroutine.close would not respect the expected number of results from the protected call.
* A coroutine can close itselfRoberto Ierusalimschy2025-06-126-21/+103
| | | | | A call to close itself will close all its to-be-closed variables and return to the resume that (re)started the coroutine.
* Loading a binary chunk should not break assertionsRoberto Ierusalimschy2025-06-042-1/+4
| | | | | Although the execution of a bad binary chunk can crash the interpreter, simply loading it should be safe.
* Removed uneeded check in parserRoberto Ierusalimschy2025-06-041-1/+0
| | | | | | | | | In a constructor, each field generates at least one opcode, and the number of opcodes is limited by INT_MAX. Therefore, the counters for number of fields cannot exceed this limit. (The current limit for items in the hash part of a table has a limit smaller than INT_MAX. However, as long as there are no overflows, the logic for table resizing will handle that limit.)
* Bug: check for constructor overflow in [exp] fieldsRoberto Ierusalimschy2025-05-202-6/+5
| | | | | The check for constructor overflow was considering only fields with explicit names, ignoring fields with syntax '[exp]=exp'.
* New way to control preambular declarationRoberto Ierusalimschy2025-05-204-15/+45
| | | | | Validity of the preambular global declaration in controled together with all declarations, when checking variable names.
* Proper error message when jumping into 'global *'Roberto Ierusalimschy2025-05-183-9/+12
| | | | | | A goto cannot jump into the scope of any variable declaration, including 'global *'. To report the error, it needs a "name" for the scope it is entering.
* Variable attributes can prefix name listRoberto Ierusalimschy2025-05-1815-60/+84
| | | | | In this format, the attribute applies to all names in the list; e.g. "global<const> print, require, math".
* DetailRoberto Ierusalimschy2025-05-162-8/+7
| | | | | Reports errors with "?:?:" (instead of "?:-1:") when there is no debug information.
* Slightly faster way to check for "global"Roberto Ierusalimschy2025-05-163-12/+13
|
* Internalized string "break" kept by the parserRoberto Ierusalimschy2025-05-153-3/+7
| | | | | | The parser uses "break" as fake label to compile "break" as "goto break". To avoid producing this string at each use, it keeps it available in its state.
* Remove compat code in parser when not neededRoberto Ierusalimschy2025-05-132-2/+5
|
* Collective declaration for globals ('global *')Roberto Ierusalimschy2025-05-1314-63/+155
|
* Correct line in error message for constant functionRoberto Ierusalimschy2025-05-122-1/+8
|
* 'expdesc' doesn't depend on 'actvar' for var. info.Roberto Ierusalimschy2025-05-113-17/+23
| | | | | In preparation for 'global *', the structure 'expdesc' does not point to 'actvar.arr' for information about global variables.
* Janitorial work on castsRoberto Ierusalimschy2025-05-088-44/+47
|
* Using 'l_uint32' for unicode codepoints in scannerRoberto Ierusalimschy2025-05-084-7/+7
| | | | | 'l_uint32' is enough for unicode codepoints (versus unsigned long), and the utf-8 library already uses that type.
* New syntax 'global function'Roberto Ierusalimschy2025-05-084-13/+82
|
* Checks for read-only globalsRoberto Ierusalimschy2025-05-064-9/+33
|
* First implementation of global declarationsRoberto Ierusalimschy2025-05-0510-117/+272
|
* New macro 'pushvfstring'Roberto Ierusalimschy2025-04-234-16/+13
| | | | | Helps to ensure that 'luaO_pushvfstring' is being called correctly, with an error check after closing the vararg list with 'va_end'.
* Details (typos in comments)Roberto Ierusalimschy2025-04-2316-30/+29
|
* Function 'luaK_semerror' made varargRoberto Ierusalimschy2025-04-173-20/+21
| | | | | All calls to 'luaK_semerror' were using 'luaO_pushfstring' to create the error messages.
* In gen. GC, some gray objects stay in gray listsRoberto Ierusalimschy2025-04-152-2/+9
| | | | | | In generational collection, objects marked as touched1 stay in gray lists between collections. This commit fixes a bug introduced in commit 808976bb59.
* Order change in 'pushfuncname'Roberto Ierusalimschy2025-04-032-7/+7
| | | | | 'pushglobalfuncname' can be quite slow (as it traverses all globals and all loaded modules), so try first to get a name from the code.
* Tiny refactoring in io.flushRoberto Ierusalimschy2025-04-032-7/+25
|
* io.write returns number of written bytes on errorRoberto Ierusalimschy2025-04-034-7/+65
|
* Corrections of stack addresses back to strict modeRoberto Ierusalimschy2025-04-012-3/+3
| | | | | | It can be a little slower, but only for quite large stacks and moreover stack reallocation is not a common operation. With no strong contrary reason, it is better to follow the standard.