Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions code/client/snd_mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ void S_SetVoiceAmplitudeFrom16( const sfx_t *sc, int sampleOffset, int count, in
for ( i = 0; i < count; i++ ) {
if ( sampleOffset >= SND_CHUNK_SIZE ) {
chunk = chunk->next;
if ( !chunk ) {
chunk = sc->soundData;
}
samples = chunk->sndChunk;
sampleOffset = 0;
}
Expand Down Expand Up @@ -528,6 +531,9 @@ static void S_PaintChannelFrom16_scalar( channel_t *ch, const sfx_t *sc, int cou

if (sampleOffset == SND_CHUNK_SIZE) {
chunk = chunk->next;
if ( !chunk ) {
chunk = sc->soundData;
}
samples = chunk->sndChunk;
sampleOffset = 0;
}
Expand Down Expand Up @@ -703,6 +709,9 @@ void S_PaintChannelFromMuLaw( channel_t *ch, sfx_t *sc, int count, int sampleOff
samples++;
if (chunk != NULL && samples == (byte *)chunk->sndChunk+(SND_CHUNK_SIZE*2)) {
chunk = chunk->next;
if ( !chunk ) {
chunk = sc->soundData;
}
samples = (byte *)chunk->sndChunk;
}
}
Expand Down
14 changes: 12 additions & 2 deletions code/qcommon/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,18 @@ Com_StringContains
*/
char *Com_StringContains( char *str1, char *str2, int casesensitive ) {
int len, i, j;

len = strlen( str1 ) - strlen( str2 );
size_t l1, l2;

l1 = strlen( str1 );
l2 = strlen( str2 );
if ( l2 > l1 ) {
// substring is longer than haystack; the loop below would
// not execute, but the unsigned subtraction would underflow
// before being truncated into int and produce indeterminate
// loop bounds. Bail explicitly.
return NULL;
}
len = (int)( l1 - l2 );
for ( i = 0; i <= len; i++, str1++ ) {
for ( j = 0; str2[j]; j++ ) {
if ( casesensitive ) {
Expand Down