Check if chunk is empty in luaL_loadbufferx for Luau (fixes #200)

This commit is contained in:
Alex Orlenko 2022-08-23 11:35:08 +01:00
parent 20a16839aa
commit 33278d4a64
No known key found for this signature in database
GPG key ID: 4C150C250863B96D
2 changed files with 2 additions and 1 deletions

View file

@ -341,7 +341,7 @@ pub unsafe fn luaL_loadbufferx(
fn free(p: *mut c_void);
}
let chunk_is_text = (*data as u8) >= b'\n';
let chunk_is_text = size == 0 || (*data as u8) >= b'\n';
if !mode.is_null() {
let modeb = CStr::from_ptr(mode).to_bytes();
if !chunk_is_text && !modeb.contains(&b'b') {

View file

@ -73,6 +73,7 @@ fn test_load() -> Result<()> {
let result: i32 = func.call(())?;
assert_eq!(result, 3);
assert!(lua.load("").exec().is_ok());
assert!(lua.load("§$%§&$%&").exec().is_err());
Ok(())