From: Xuemin Su Date: Tue, 30 Oct 2012 05:09:00 +0000 (+0800) Subject: compress: fix arithmetic exception in compress_get_hpointer X-Git-Tag: v0.1.0~15 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=09318702910e4503cff552a0fef1b13210342483;p=tinycompress.git compress: fix arithmetic exception in compress_get_hpointer In compress_get_hpointer, check for invalid sample rate to prevent devide-by-zero exceptions Signed-off-by: Xuemin Su Signed-off-by: He Bo Signed-off-by: Vinod Koul --- diff --git a/compress.c b/compress.c index b035e4a..27c03d9 100644 --- a/compress.c +++ b/compress.c @@ -286,6 +286,8 @@ int compress_get_hpointer(struct compress *compress, if (ioctl(compress->fd, SNDRV_COMPRESS_AVAIL, &kavail)) return oops(compress, errno, "cannot get avail"); + if (0 == kavail.tstamp.sampling_rate) + return oops(compress, errno, "invalid paramter"); *avail = (unsigned int)kavail.avail; time = kavail.tstamp.pcm_io_frames / kavail.tstamp.sampling_rate; tstamp->tv_sec = time;