mirror of
https://github.com/neovim/neovim.git
synced 2026-03-28 03:12:00 +00:00
fix(api): nvim_set_hl crashes when url= key is passed
Problem: Calling nvim_set_hl() with url= crashes because it tries to free arena-owned string memory. Solution: Remove the bad free and return a validation error instead.
This commit is contained in:
committed by
Christian Clason
parent
bfc7bae421
commit
d19dc6339d
@@ -184,8 +184,8 @@ void nvim_set_hl(uint64_t channel_id, Integer ns_id, String name, Dict(highlight
|
||||
|
||||
// Setting URLs directly through highlight attributes is not supported
|
||||
if (HAS_KEY(val, highlight, url)) {
|
||||
api_free_string(val->url);
|
||||
val->url = NULL_STRING;
|
||||
api_set_error(err, kErrorTypeValidation, "Invalid Key: 'url'");
|
||||
return;
|
||||
}
|
||||
|
||||
HlAttrs attrs = dict2hlattrs(val, true, &link_id, err);
|
||||
|
||||
@@ -254,6 +254,10 @@ describe('API: set highlight', function()
|
||||
)
|
||||
assert_alive()
|
||||
end)
|
||||
it("'url' is rejected with an error #38162", function()
|
||||
eq("Invalid Key: 'url'", pcall_err(api.nvim_set_hl, 0, 'Test', { url = 'https://example.com' }))
|
||||
assert_alive()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('API: get highlight', function()
|
||||
|
||||
Reference in New Issue
Block a user