Skip to content

Commit f4c40b8

Browse files
committed
pulse: fix possible overflow for buffer_time option
The int cast is wrong and unnecessary as internal->buffer_time is a pa_usec_t (which is uint64_t). It does not even make sense to cast it to a uint as it being multiplied by the sample rate (and then divided by 1000000 before it get fitted into battr.tlength, which is a uint32_t). Also ditch the "+7" trick for format->bits as the function would have returned already if it isn't 8/16(/24).
1 parent d522165 commit f4c40b8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/plugins/pulse/ao_pulse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ int ao_plugin_open(ao_device *device, ao_sample_format *format) {
258258
/* buffering attributes */
259259
battr.prebuf = battr.minreq = battr.fragsize = -1;
260260

261-
battr.tlength = (int)(internal->buffer_time * format->rate) / 1000000 *
262-
((format->bits+7)/8) * device->output_channels;
261+
battr.tlength = internal->buffer_time * format->rate / 1000000 *
262+
(format->bits / 8) * device->output_channels;
263263
battr.minreq = battr.tlength/4;
264264
battr.maxlength = battr.tlength+battr.minreq;
265265

0 commit comments

Comments
 (0)