forked from Archive/PX4-Autopilot
Fixed pwm count check
This commit is contained in:
parent
a16d60e825
commit
d2c5990d6f
|
@ -205,12 +205,12 @@ pwm_main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
unsigned pwm_value = strtol(arg, &ep, 0);
|
unsigned pwm_value = strtol(arg, &ep, 0);
|
||||||
if (*ep == '\0') {
|
if (*ep == '\0') {
|
||||||
|
if (nchannels > sizeof(channel) / sizeof(channel[0]))
|
||||||
|
err(1, "too many pwm values (max %d)", sizeof(channel) / sizeof(channel[0]));
|
||||||
|
|
||||||
channel[nchannels] = pwm_value;
|
channel[nchannels] = pwm_value;
|
||||||
nchannels++;
|
nchannels++;
|
||||||
|
|
||||||
if (nchannels >= sizeof(channel) / sizeof(channel[0]))
|
|
||||||
err(1, "too many pwm values (max %d)", sizeof(channel) / sizeof(channel[0]));
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
usage("unrecognized option");
|
usage("unrecognized option");
|
||||||
|
|
Loading…
Reference in New Issue