Fix lifetime of `DebugNames` in `Debug::names()` and `DebugSource` in `Debug::source()`.

This can cause use-after-free if used wrong.
Now invalid code would not compile.
Reported in #230
This commit is contained in:
Alex Orlenko 2022-12-09 23:55:38 +00:00
parent c88417a3b6
commit 9716918517
No known key found for this signature in database
GPG Key ID: 4C150C250863B96D
1 changed files with 2 additions and 2 deletions

View File

@ -63,7 +63,7 @@ impl<'lua> Debug<'lua> {
}
/// Corresponds to the `n` what mask.
pub fn names(&self) -> DebugNames<'lua> {
pub fn names(&self) -> DebugNames {
unsafe {
#[cfg(not(feature = "luau"))]
mlua_assert!(
@ -87,7 +87,7 @@ impl<'lua> Debug<'lua> {
}
/// Corresponds to the `S` what mask.
pub fn source(&self) -> DebugSource<'lua> {
pub fn source(&self) -> DebugSource {
unsafe {
#[cfg(not(feature = "luau"))]
mlua_assert!(