From d60317c153b8bc72b4e22cf3fba2f6c3d9a668a3 Mon Sep 17 00:00:00 2001 From: Raymond Chandler Date: Tue, 19 Mar 2013 22:32:40 -0400 Subject: [PATCH] FS-5091 --resolve avoid division by 0 --- src/mod/formats/mod_shout/mod_shout.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mod/formats/mod_shout/mod_shout.c b/src/mod/formats/mod_shout/mod_shout.c index 6d00f7ab38..e3fda4bef9 100644 --- a/src/mod/formats/mod_shout/mod_shout.c +++ b/src/mod/formats/mod_shout/mod_shout.c @@ -208,6 +208,7 @@ static inline void free_context(shout_context_t *context) unsigned char mp3buffer[8192]; int len; int16_t blank[2048] = { 0 }, *r = NULL; + int framesize; if (context->channels == 2) { r = blank; @@ -222,13 +223,16 @@ static inline void free_context(shout_context_t *context) } } - while ((len = lame_encode_flush(context->gfp, mp3buffer, sizeof(mp3buffer))) > 0) { - ret = shout_send(context->shout, mp3buffer, len); + framesize = lame_get_framesize(context->gfp); + if ( framesize ) { + while ((len = lame_encode_flush(context->gfp, mp3buffer, sizeof(mp3buffer))) > 0) { + ret = shout_send(context->shout, mp3buffer, len); - if (ret != SHOUTERR_SUCCESS) { - break; - } else { - shout_sync(context->shout); + if (ret != SHOUTERR_SUCCESS) { + break; + } else { + shout_sync(context->shout); + } } } }