From 1c0d9f01b1698d1571803e07d8eaeccf5be4ba3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Thu, 2 Jan 2025 13:16:11 -0500 Subject: [PATCH] Some especially silly Coverity-induced paranoia. --- src/xpdev/xpbeep.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/xpdev/xpbeep.c b/src/xpdev/xpbeep.c index c7a74101b9..ddd3b6e022 100644 --- a/src/xpdev/xpbeep.c +++ b/src/xpdev/xpbeep.c @@ -834,7 +834,7 @@ do_xp_play_sample(unsigned char *sampo, size_t sz, int *freed) int need_copy = 0; #endif #ifdef AFMT_U8 - int wr; + size_t wr; int i; #endif @@ -976,12 +976,15 @@ do_xp_play_sample(unsigned char *sampo, size_t sz, int *freed) #endif #ifdef AFMT_U8 - if(handle_type==SOUND_DEVICE_OSS) { - wr=0; - while(wr<sz) { - i=write(dsp, samp+wr, sz-wr); - if(i>=0) - wr+=i; + if (handle_type == SOUND_DEVICE_OSS) { + wr = 0; + while (wr < sz) { + i = write(dsp, samp + wr, sz - wr); + if (i >= 0) { + if ((SIZE_MAX - i) < wr) + wr = SIZE_MAX; + wr += i; + } } return true; } -- GitLab