forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lua: prevent serialization of error for ucdata
Without checking the return value of lua_pcall()` in `lua_field_inspect_ucdata()`, the error message itself is returned as a serialized result. The result status of `lua_pcall()` is not ignored now. NO_DOC=bugfix Closes tarantool#9396 (cherry picked from commit 98474f7)
- Loading branch information
1 parent
2e9d205
commit 074fe0b
Showing
3 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## bugfix/lua | ||
|
||
* An error from a serializer function for cdata and userdata is not ignored now | ||
(gh-9396). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local t = require('luatest') | ||
local g = t.group() | ||
|
||
-- XXX: Use `yaml.encode()` to trigger a serialization error. | ||
local yaml = require('yaml') | ||
|
||
local ERRMSG = 'error in serializer' | ||
|
||
g.test_error_in_ucdata_serializer = function() | ||
local ud_mt = {__serialize = function() | ||
error(ERRMSG) | ||
end} | ||
ud_mt.__index = ud_mt | ||
local ud = newproxy(true) | ||
debug.setmetatable(ud, ud_mt) | ||
-- XXX: This helper fails if there is no error raised. | ||
t.assert_error_msg_matches('.*' .. ERRMSG, yaml.encode, ud) | ||
end |