From 8a0ae244a120bb0d9c603c69c37d1de359bc08ec Mon Sep 17 00:00:00 2001 From: "J?rgen P. Tjern?" Date: Tue, 23 Jul 2013 17:40:13 -0700 Subject: [PATCH] Fix some clang analyzer warnings. This fixes some analyzer warnings and a couple of minor memory leaks. --- src/events/SDL_gesture.c | 2 +- src/render/SDL_render.c | 2 +- src/video/SDL_surface.c | 2 ++ src/video/SDL_video.c | 7 +++++-- src/video/cocoa/SDL_cocoaevents.m | 6 +++++- src/video/cocoa/SDL_cocoashape.m | 1 + 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index 8e764318a..f0a62c002 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -392,7 +392,7 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) 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; diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index c87ba2f14..383ba456e 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -1467,7 +1467,7 @@ SDL_RenderDrawRects(SDL_Renderer * renderer, int SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect) { - SDL_Rect full_rect; + SDL_Rect full_rect = {}; CHECK_RENDERER_MAGIC(renderer, -1); diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 17f253c2c..594964181 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -619,6 +619,8 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, /* 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; } diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 8b3c2f073..21b46523b 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -3062,8 +3062,11 @@ static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messagebo } 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 diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index 61d6e1596..c1d40c0f2 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -138,6 +138,10 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam NSMenu *windowMenu; NSMenuItem *menuItem; + if (!NSApp) { + return; + } + /* Create the main menu bar */ [NSApp setMainMenu:[[NSMenu alloc] init]]; @@ -228,7 +232,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam } [NSApp finishLaunching]; } - if ([NSApp delegate] == nil) { + if (NSApp && ![NSApp delegate]) { [NSApp setDelegate:[[SDLAppDelegate alloc] init]]; } [pool release]; diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m index 1be93dedb..71085261a 100644 --- a/src/video/cocoa/SDL_cocoashape.m +++ b/src/video/cocoa/SDL_cocoashape.m @@ -96,6 +96,7 @@ closure.window = shaper->window; SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure); [closure.path addClip]; + [pool release]; return 0; }