diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-06-09 12:41:47 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-06-09 12:41:47 +0200 |
commit | d2c5990d6f0b1c3f4183a193c1c51250cbdfa127 (patch) | |
tree | a5f0e59a1395f988fbd9e993a29a96330a0deabf /src | |
parent | a16d60e825d599cf944def0e1cfcab30655d1993 (diff) | |
download | px4-firmware-d2c5990d6f0b1c3f4183a193c1c51250cbdfa127.tar.gz px4-firmware-d2c5990d6f0b1c3f4183a193c1c51250cbdfa127.tar.bz2 px4-firmware-d2c5990d6f0b1c3f4183a193c1c51250cbdfa127.zip |
Fixed pwm count check
Diffstat (limited to 'src')
-rw-r--r-- | src/systemcmds/pwm/pwm.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/systemcmds/pwm/pwm.c b/src/systemcmds/pwm/pwm.c index 570ca6aa9..619bd2c78 100644 --- a/src/systemcmds/pwm/pwm.c +++ b/src/systemcmds/pwm/pwm.c @@ -205,12 +205,12 @@ pwm_main(int argc, char *argv[]) } unsigned pwm_value = strtol(arg, &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; nchannels++; - if (nchannels >= sizeof(channel) / sizeof(channel[0])) - err(1, "too many pwm values (max %d)", sizeof(channel) / sizeof(channel[0])); - continue; } usage("unrecognized option"); |