A few minor changes to placate static analysis.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
index 18d2c26..4842101 100644
--- a/src/audio/SDL_wave.c
+++ b/src/audio/SDL_wave.c
@@ -1240,7 +1240,8 @@ LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return SDL_SetError("WAVE file too big");
}
- src = (Uint8 *)SDL_realloc(chunk->data, expanded_len);
+ /* 1 to avoid allocating zero bytes, to keep static analysis happy. */
+ src = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
if (src == NULL) {
return SDL_OutOfMemory();
}
@@ -1371,7 +1372,8 @@ PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return SDL_SetError("WAVE file too big");
}
- ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len);
+ /* 1 to avoid allocating zero bytes, to keep static analysis happy. */
+ ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
if (ptr == NULL) {
return SDL_OutOfMemory();
}
diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m
index 4769944..b774626 100644
--- a/src/video/cocoa/SDL_cocoamouse.m
+++ b/src/video/cocoa/SDL_cocoamouse.m
@@ -424,7 +424,11 @@ void
Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
{
SDL_Mouse *mouse = SDL_GetMouse();
- SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
+ if (!mouse) {
+ return;
+ }
+
+ SDL_MouseID mouseID = mouse->mouseID;
if ([event subtype] == NSEventSubtypeTouch) { /* this is a synthetic from the OS */
if (mouse->touch_mouse_events) {
mouseID = SDL_TOUCH_MOUSEID; /* Hint is set */
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index f4911e3..68ea198 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -894,7 +894,11 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
- (void)mouseDown:(NSEvent *)theEvent
{
const SDL_Mouse *mouse = SDL_GetMouse();
- SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
+ if (!mouse) {
+ return;
+ }
+
+ SDL_MouseID mouseID = mouse->mouseID;
int button;
int clicks;
@@ -959,7 +963,11 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
- (void)mouseUp:(NSEvent *)theEvent
{
const SDL_Mouse *mouse = SDL_GetMouse();
- SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
+ if (!mouse) {
+ return;
+ }
+
+ SDL_MouseID mouseID = mouse->mouseID;
int button;
int clicks;
@@ -1014,7 +1022,11 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
- (void)mouseMoved:(NSEvent *)theEvent
{
SDL_Mouse *mouse = SDL_GetMouse();
- SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
+ if (!mouse) {
+ return;
+ }
+
+ SDL_MouseID mouseID = mouse->mouseID;
SDL_Window *window = _data->window;
NSPoint point;
int x, y;