Skip to content

Commit

Permalink
Fix in the definition of 'sizeLclosure'
Browse files Browse the repository at this point in the history
The array at the end of a Lua closure has pointers to upvalues, not
to tagged values. This bug cannot cause any issue: The ISO C standard
requires that all pointers to structures have the same representation,
so sizeof(TValue*) must be equal to sizeof(UpVal*).
  • Loading branch information
roberto-ieru committed Dec 3, 2024
1 parent 04e4954 commit 975d4e0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
(offsetof(CClosure, upvalue) + sizeof(TValue) * cast_uint(n))

#define sizeLclosure(n) \
(offsetof(LClosure, upvals) + sizeof(TValue *) * cast_uint(n))
(offsetof(LClosure, upvals) + sizeof(UpVal *) * cast_uint(n))


/* test whether thread is in 'twups' list */
Expand Down

0 comments on commit 975d4e0

Please sign in to comment.