From 61b46199accad5ece60e379d0b5b9bb4555b20fd Mon Sep 17 00:00:00 2001 From: "Jørgen P. Tjernø" Date: Tue, 23 Jul 2013 17:40:13 -0700 Subject: 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(-) (limited to 'src') diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index 8e764318a5..f0a62c002e 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 c87ba2f14d..383ba456eb 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 17f253c2c5..5949641819 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 8b3c2f0732..21b46523b9 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 61d6e15969..c1d40c0f22 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -138,6 +138,10 @@ CreateApplicationMenus(void) NSMenu *windowMenu; NSMenuItem *menuItem; + if (!NSApp) { + return; + } + /* Create the main menu bar */ [NSApp setMainMenu:[[NSMenu alloc] init]]; @@ -228,7 +232,7 @@ Cocoa_RegisterApp(void) } [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 1be93dedb1..71085261aa 100644 --- a/src/video/cocoa/SDL_cocoashape.m +++ b/src/video/cocoa/SDL_cocoashape.m @@ -96,6 +96,7 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape closure.window = shaper->window; SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure); [closure.path addClip]; + [pool release]; return 0; } -- cgit v1.2.3