Skip to content

Commit

Permalink
avoid FPE when number of channels is zero. Fix MestreLion#6
Browse files Browse the repository at this point in the history
  • Loading branch information
MestreLion committed Jul 5, 2020
1 parent d04aa42 commit eec00e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,9 @@ int wav_open(FILE *in, wavegain_opt *opt,
of trying to abstract stuff. */
wav->samplesize = format.samplesize;

if (len)
if (!format.channels)
opt->total_samples_per_channel = 0;
else if (len)
opt->total_samples_per_channel = len/(format.channels*samplesize);
else {
Int64_t pos;
Expand Down
3 changes: 2 additions & 1 deletion wavegain.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ int get_gain(const char *filename, double *track_peak, double *track_gain,
}

if ((wg_opts->channels != 1) && (wg_opts->channels != 2)) {
fprintf(stderr, " Unsupported number of channels.\n");
fprintf(stderr, " Unsupported number of channels (%d) for %s.\n",
wg_opts->channels, filename);
goto exit;
}

Expand Down

0 comments on commit eec00e2

Please sign in to comment.