aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/flac_metadata.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-07-03 14:57:56 +0200
committerMax Kellermann <max@duempel.org>2011-07-03 14:57:56 +0200
commit6aa6a9c2727c863239d6396a40a781e98e922565 (patch)
treee67b32b7cf6cffdfc11f4a76db2d9ae190469453 /src/decoder/flac_metadata.h
parent8d1c7ca2065444dfe2da432a30c95782e3ead48d (diff)
downloadmpd-6aa6a9c2727c863239d6396a40a781e98e922565.tar.gz
mpd-6aa6a9c2727c863239d6396a40a781e98e922565.tar.xz
mpd-6aa6a9c2727c863239d6396a40a781e98e922565.zip
decoder/flac: validate the sample rate when scanning the tag
Don't calculate the song duration when the sample rate is 0 (division by zero crash).
Diffstat (limited to 'src/decoder/flac_metadata.h')
-rw-r--r--src/decoder/flac_metadata.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/decoder/flac_metadata.h b/src/decoder/flac_metadata.h
index 06e691d1d..e52b0fb82 100644
--- a/src/decoder/flac_metadata.h
+++ b/src/decoder/flac_metadata.h
@@ -20,6 +20,7 @@
#ifndef MPD_FLAC_METADATA_H
#define MPD_FLAC_METADATA_H
+#include <assert.h>
#include <stdbool.h>
#include <FLAC/metadata.h>
@@ -29,6 +30,8 @@ struct replay_gain_info;
static inline unsigned
flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info)
{
+ assert(stream_info->sample_rate > 0);
+
return (stream_info->total_samples + stream_info->sample_rate - 1) /
stream_info->sample_rate;
}