Fix audio file length misscalculated due to overflow.

`s_info->samples' is very big, even for short wave files. Multiply it by
1000 has a very high chance of flowing over and it is a wonder that so
 far no one noticed it. Fix the overflow by working on 64 bit integers.

 Closes #931.
This commit is contained in:
Yamagi 2022-11-19 16:54:52 +01:00
parent 8b12b017f7
commit a1e0ce0732

View file

@ -34,6 +34,8 @@
#ifdef USE_OPENAL
#include <stdint.h>
#include "../header/client.h"
#include "header/local.h"
#include "header/qal.h"
@ -206,7 +208,7 @@ AL_UploadSfx(sfx_t *s, wavinfo_t *s_info, byte *data, short volume,
/* allocate placeholder sfxcache */
sc = s->cache = Z_TagMalloc(sizeof(*sc), 0);
sc->length = s_info->samples * 1000 / s_info->rate;
sc->length = ((uint64_t)s_info->samples * 1000) / s_info->rate;
sc->loopstart = s_info->loopstart;
sc->width = s_info->width;
sc->size = size;