Skip to content

Commit

Permalink
silence audio filter: fixed build
Browse files Browse the repository at this point in the history
strdupa compat not included but not needed, VLA can be used
  • Loading branch information
MartinPulec committed Jul 26, 2023
1 parent 2f1bfa9 commit bb53aae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/audio/filter/silence.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ init(struct module *parent, const char *cfg, void **state)
}
struct state_silence *s = calloc(1, sizeof *s);

char *fmt = strdupa(cfg);
const size_t len = strlen(cfg) + 1;
char fmt[len];
strncpy(fmt, cfg, len);
char *tmp = fmt;
char *item = NULL;
char *end_ptr = NULL;
while ((item = strtok_r(fmt, ",", &end_ptr)) != NULL) {
while ((item = strtok_r(tmp, ",", &end_ptr)) != NULL) {
assert(s->silence_channels_count < MAX_CHANNELS - 1);
s->silence_channels[s->silence_channels_count++] =
strtol(item, NULL, 10);
fmt = NULL;
tmp = NULL;
}
*state = s;
return AF_OK;
Expand Down

0 comments on commit bb53aae

Please sign in to comment.