mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
lua/executor: Fix crash when printing empty string (#7157)
This commit is contained in:
parent
e6c528d9fc
commit
d0cb175cab
@ -519,7 +519,7 @@ static int nlua_print(lua_State *const lstate)
|
|||||||
}
|
}
|
||||||
msg((char_u *)str + start);
|
msg((char_u *)str + start);
|
||||||
}
|
}
|
||||||
if (str[len - 1] == NUL) { // Last was newline
|
if (len && str[len - 1] == NUL) { // Last was newline
|
||||||
msg((char_u *)"");
|
msg((char_u *)"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,13 @@ describe('print', function()
|
|||||||
eq('\nT^@', redir_exec([[lua print("T\0")]]))
|
eq('\nT^@', redir_exec([[lua print("T\0")]]))
|
||||||
eq('\nT\n', redir_exec([[lua print("T\n")]]))
|
eq('\nT\n', redir_exec([[lua print("T\n")]]))
|
||||||
end)
|
end)
|
||||||
|
it('prints empty strings correctly', function()
|
||||||
|
-- Regression: first test used to crash
|
||||||
|
eq('', redir_exec('lua print("")'))
|
||||||
|
eq('\n def', redir_exec('lua print("", "def")'))
|
||||||
|
eq('\nabc ', redir_exec('lua print("abc", "")'))
|
||||||
|
eq('\nabc def', redir_exec('lua print("abc", "", "def")'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('debug.debug', function()
|
describe('debug.debug', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user