uORB: fix node_open: *instance is read even though it's an output parameter

This fixes a subtle bug: the instance parameter of orb_advertise is an output
parameter and thus its value can be random. However in node_open this value
is accessed and thus the open(...) call could succeed even though it should
not. This can happen for example if a second advertiser of a topic calls
orb_advertise_multi with *instance=0.

The existing implementation worked only because *instance was initialized
with -1 in most cases.
This commit is contained in:
Beat Küng
2016-04-15 12:46:49 +02:00
committed by tumbili
parent 995710da00
commit 9c360e9f88
4 changed files with 33 additions and 41 deletions
+4
View File
@@ -94,6 +94,10 @@ uorb_main(int argc, char *argv[])
* Test the driver/device.
*/
if (!strcmp(argv[1], "test")) {
if (!g_dev) {
PX4_WARN("orb is not running! start it first");
return -ESRCH;
}
uORBTest::UnitTest &t = uORBTest::UnitTest::instance();
return t.test();
}