From 778e8185cddc6c6c206db642b32dbc735851f933 Mon Sep 17 00:00:00 2001
From: Mathieu Eyraud <[EMAIL REDACTED]>
Date: Sat, 5 Aug 2023 18:58:30 +0200
Subject: [PATCH] Fix size of memcpy in
SDL_AudioDeviceFormatChangedAlreadyLocked And add diagnostic that allows to
find this kind of issue in clang-tidy
---
.clang-tidy | 1 +
src/audio/SDL_audio.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/.clang-tidy b/.clang-tidy
index 739a8eb0417a..b46d0de57912 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -25,6 +25,7 @@ Checks: >
clang-analyzer-core.*,
clang-analyzer-valist.*,
clang-analyzer-unix.Malloc,
+ clang-diagnostic-*,
google-readability-casting,
misc-misleading-bidirectional,
misc-misleading-identifier,
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index dd1d2af1b414..bacd4b89caf2 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -1681,7 +1681,7 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL
const SDL_bool iscapture = device->iscapture;
if ((device->spec.format != newspec->format) || (device->spec.channels != newspec->channels) || (device->spec.freq != newspec->freq)) {
- SDL_memcpy(&device->spec, newspec, sizeof (newspec));
+ SDL_memcpy(&device->spec, newspec, sizeof (*newspec));
for (SDL_LogicalAudioDevice *logdev = device->logical_devices; !kill_device && (logdev != NULL); logdev = logdev->next) {
for (SDL_AudioStream *stream = logdev->bound_streams; !kill_device && (stream != NULL); stream = stream->next_binding) {
if (SDL_SetAudioStreamFormat(stream, iscapture ? &device->spec : NULL, iscapture ? NULL : &device->spec) == -1) {