Skip to content

Commit

Permalink
blockdiagram: correct check for non-existing configs
Browse files Browse the repository at this point in the history
In luajit checking a cdata for being NULL can not be done by negating
it (it is a boxed value, so that evaluates to false). Instead, it must
be explicitely compared against nil.

This problem was previously hidden because block_config_get would
throw an error if a config of the given name didn't exist. Since that
function was updated to just return NULL this problem could occur.

Reported-by: Hamish Guthrie <hamish.guthrie@kistler.com>
Signed-off-by: Markus Klotzbuecher <mk@mkio.de>
  • Loading branch information
kmarkus committed Sep 16, 2019
1 parent dc9168f commit d8efc41
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/blockdiagram.lua
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,11 @@ function system.launch(self, t)
err_exit(1, "invalid node config reference '"..val.."'")
end
local blkcfg = ubx.block_config_get(b, name)
if not blkcfg then

if blkcfg==nil then
err_exit(1, "non-existing config '"..blkconf.name.. "."..name.."'")
end

ubx.config_assign(blkcfg, _NC[nodecfg])
info("cfg "..green(blkconf.name.."."..blue(name))..
" -> node cfg "..yellow(nodecfg))
Expand Down

0 comments on commit d8efc41

Please sign in to comment.