mirror of
https://github.com/openharmony/third_party_tinyalsa.git
synced 2026-07-19 23:33:30 -04:00
pcm: Fix integer size error.
The following code:
while (pcm->boundary * 2 <= LONG_MAX - pcm->buffer_size)
pcm->boundary *= 2;
Creates an infinite loop on systems where LONG_MAX != INT_MAX
(e.g. 64-bit systems). pcm->boundary is an unsigned int, and so
INT_MAX is the proper value to use.
This commit is contained in:
@@ -558,7 +558,7 @@ struct pcm *pcm_open(unsigned int card, unsigned int device,
|
||||
sparams.silence_threshold = config->silence_threshold;
|
||||
pcm->boundary = sparams.boundary = pcm->buffer_size;
|
||||
|
||||
while (pcm->boundary * 2 <= LONG_MAX - pcm->buffer_size)
|
||||
while (pcm->boundary * 2 <= INT_MAX - pcm->buffer_size)
|
||||
pcm->boundary *= 2;
|
||||
|
||||
if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sparams)) {
|
||||
|
||||
Reference in New Issue
Block a user