aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-10-16 18:05:34 +0200
committerMax Kellermann <max@duempel.org>2015-10-16 18:05:34 +0200
commit4e3d1821895c92d060fc3a9059e83ac58c8c79a3 (patch)
treecc543ced3ce48fe52f5134b5ab86fa1aa3faeedb
parent205fba74cffffb9df985cdf928101633ffc41772 (diff)
downloadmpd-4e3d1821895c92d060fc3a9059e83ac58c8c79a3.tar.gz
mpd-4e3d1821895c92d060fc3a9059e83ac58c8c79a3.tar.xz
mpd-4e3d1821895c92d060fc3a9059e83ac58c8c79a3.zip
encoder/flac: fix crash with 32 bit playback
Copy to encoder->audio_format *after* adjusting the sample format to S24_P32. Fixes http://bugs.musicpd.org/view.php?id=4433
-rw-r--r--NEWS2
-rw-r--r--src/encoder/plugins/FlacEncoderPlugin.cxx4
2 files changed, 4 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 7e5f41b3b..9c44eaf0a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
ver 0.19.11 (not yet released)
* tags
- ape: fix buffer overflow
+* encoder
+ - flac: fix crash with 32 bit playback
ver 0.19.10 (2015/06/21)
* input
diff --git a/src/encoder/plugins/FlacEncoderPlugin.cxx b/src/encoder/plugins/FlacEncoderPlugin.cxx
index 26987fe99..9317b02ea 100644
--- a/src/encoder/plugins/FlacEncoderPlugin.cxx
+++ b/src/encoder/plugins/FlacEncoderPlugin.cxx
@@ -157,8 +157,6 @@ flac_encoder_open(Encoder *_encoder, AudioFormat &audio_format, Error &error)
struct flac_encoder *encoder = (struct flac_encoder *)_encoder;
unsigned bits_per_sample;
- encoder->audio_format = audio_format;
-
/* FIXME: flac should support 32bit as well */
switch (audio_format.format) {
case SampleFormat::S8:
@@ -178,6 +176,8 @@ flac_encoder_open(Encoder *_encoder, AudioFormat &audio_format, Error &error)
audio_format.format = SampleFormat::S24_P32;
}
+ encoder->audio_format = audio_format;
+
/* allocate the encoder */
encoder->fse = FLAC__stream_encoder_new();
if (encoder->fse == nullptr) {