Skip to content

Commit 778e818

Browse files
meyraud705icculus
authored andcommitted
Fix size of memcpy in SDL_AudioDeviceFormatChangedAlreadyLocked
And add diagnostic that allows to find this kind of issue in clang-tidy
1 parent 4bb426a commit 778e818

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Checks: >
2525
clang-analyzer-core.*,
2626
clang-analyzer-valist.*,
2727
clang-analyzer-unix.Malloc,
28+
clang-diagnostic-*,
2829
google-readability-casting,
2930
misc-misleading-bidirectional,
3031
misc-misleading-identifier,

src/audio/SDL_audio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL
16811681
const SDL_bool iscapture = device->iscapture;
16821682

16831683
if ((device->spec.format != newspec->format) || (device->spec.channels != newspec->channels) || (device->spec.freq != newspec->freq)) {
1684-
SDL_memcpy(&device->spec, newspec, sizeof (newspec));
1684+
SDL_memcpy(&device->spec, newspec, sizeof (*newspec));
16851685
for (SDL_LogicalAudioDevice *logdev = device->logical_devices; !kill_device && (logdev != NULL); logdev = logdev->next) {
16861686
for (SDL_AudioStream *stream = logdev->bound_streams; !kill_device && (stream != NULL); stream = stream->next_binding) {
16871687
if (SDL_SetAudioStreamFormat(stream, iscapture ? &device->spec : NULL, iscapture ? NULL : &device->spec) == -1) {

0 commit comments

Comments
 (0)