Fixed warning C28182: Dereferencing NULL pointer. 'streams[j]' contains the same NULL value as 'stream' did.

This commit is contained in:
Sam Lantinga
2023-12-04 19:43:41 -08:00
parent fe6b3ab0b0
commit 226f8fde09

View File

@@ -1771,7 +1771,14 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
if (retval != 0) {
int j;
for (j = 0; j <= i; j++) {
#ifdef _MSC_VER /* Visual Studio analyzer can't tell that we've already verified streams[j] isn't NULL */
#pragma warning(push)
#pragma warning(disable : 28182)
#endif
SDL_UnlockMutex(streams[j]->lock);
#ifdef _MSC_VER
#pragma warning(pop)
#endif
}
break;
}
@@ -1782,6 +1789,10 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
// Now that everything is verified, chain everything together.
const SDL_bool iscapture = device->iscapture;
for (int i = 0; i < num_streams; i++) {
#ifdef _MSC_VER /* Visual Studio analyzer can't tell that streams[i] isn't NULL if retval is 0 */
#pragma warning(push)
#pragma warning(disable : 28182)
#endif
SDL_AudioStream *stream = streams[i];
stream->bound_device = logdev;
@@ -1800,6 +1811,9 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
}
SDL_UnlockMutex(stream->lock);
#ifdef _MSC_VER
#pragma warning(pop)
#endif
}
}