circuit_breaker: prevent param fetch failure from disabling safety switch

if the param get failed then an uninitialised stack variable was used
for the safety disable on boot. In ArduPilot that value happened to
equal the correct magic due to stack passing from caller. This forced
safety off on boot
This commit is contained in:
Andrew Tridgell
2015-12-05 06:55:52 +11:00
committed by Lorenz Meier
parent 3c349236e1
commit d290487382
+5 -4
View File
@@ -48,9 +48,10 @@
bool circuit_breaker_enabled(const char *breaker, int32_t magic)
{
int32_t val;
(void)PX4_PARAM_GET_BYNAME(breaker, &val);
return (val == magic);
int32_t val = -1;
if (PX4_PARAM_GET_BYNAME(breaker, &val) == 0 && val == magic) {
return true;
}
return false;
}