Fix some clang analyzer warnings.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Tue, 23 Jul 2013 17:40:13 -0700
changeset 7508 1f64c6874619
parent 7507 885b4aab4190
child 7509 cf7c2e3493b2
Fix some clang analyzer warnings. This fixes some analyzer warnings and a couple of minor memory leaks.
src/events/SDL_gesture.c
src/render/SDL_render.c
src/video/SDL_surface.c
src/video/SDL_video.c
src/video/cocoa/SDL_cocoaevents.m
src/video/cocoa/SDL_cocoashape.m
--- a/src/events/SDL_gesture.c	Tue Jul 23 17:38:59 2013 -0700
+++ b/src/events/SDL_gesture.c	Tue Jul 23 17:40:13 2013 -0700
@@ -392,7 +392,7 @@
 static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_GestureTouch* touch)
 {
 
-    SDL_FloatPoint points[DOLLARNPOINTS];
+    SDL_FloatPoint points[DOLLARNPOINTS] = {};
     int i;
     float bestDiff = 10000;
 
--- a/src/render/SDL_render.c	Tue Jul 23 17:38:59 2013 -0700
+++ b/src/render/SDL_render.c	Tue Jul 23 17:40:13 2013 -0700
@@ -1467,7 +1467,7 @@
 int
 SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect)
 {
-    SDL_Rect full_rect;
+    SDL_Rect full_rect = {};
 
     CHECK_RENDERER_MAGIC(renderer, -1);
 
--- a/src/video/SDL_surface.c	Tue Jul 23 17:38:59 2013 -0700
+++ b/src/video/SDL_surface.c	Tue Jul 23 17:40:13 2013 -0700
@@ -619,6 +619,8 @@
     /* If the destination rectangle is NULL, use the entire dest surface */
     if (dstrect == NULL) {
         fulldst.x = fulldst.y = 0;
+        fulldst.w = dst->w;
+        fulldst.h = dst->h;
         dstrect = &fulldst;
     }
 
--- a/src/video/SDL_video.c	Tue Jul 23 17:38:59 2013 -0700
+++ b/src/video/SDL_video.c	Tue Jul 23 17:40:13 2013 -0700
@@ -3062,8 +3062,11 @@
     }
 
     SDL_VERSION(&info.version);
-    SDL_GetWindowWMInfo(window, &info);
-    return (info.subsystem == drivertype);
+    if (!SDL_GetWindowWMInfo(window, &info)) {
+        return SDL_TRUE;
+    } else {
+        return (info.subsystem == drivertype);
+    }
 }
 
 int
--- a/src/video/cocoa/SDL_cocoaevents.m	Tue Jul 23 17:38:59 2013 -0700
+++ b/src/video/cocoa/SDL_cocoaevents.m	Tue Jul 23 17:40:13 2013 -0700
@@ -138,6 +138,10 @@
     NSMenu *windowMenu;
     NSMenuItem *menuItem;
 
+    if (!NSApp) {
+        return;
+    }
+    
     /* Create the main menu bar */
     [NSApp setMainMenu:[[NSMenu alloc] init]];
 
@@ -228,7 +232,7 @@
         }
         [NSApp finishLaunching];
     }
-    if ([NSApp delegate] == nil) {
+    if (NSApp && ![NSApp delegate]) {
         [NSApp setDelegate:[[SDLAppDelegate alloc] init]];
     }
     [pool release];
--- a/src/video/cocoa/SDL_cocoashape.m	Tue Jul 23 17:38:59 2013 -0700
+++ b/src/video/cocoa/SDL_cocoashape.m	Tue Jul 23 17:40:13 2013 -0700
@@ -96,6 +96,7 @@
     closure.window = shaper->window;
     SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
     [closure.path addClip];
+    [pool release];
 
     return 0;
 }