Fixed pwm count check

This commit is contained in:
Lorenz Meier 2013-06-09 12:41:47 +02:00
parent a16d60e825
commit d2c5990d6f
1 changed files with 3 additions and 3 deletions

View File

@ -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");