From aac51d68324323943146dc7b64b507edb5f15eaf Mon Sep 17 00:00:00 2001 From: Job Bolle Date: Sun, 15 Oct 2017 18:36:04 +0200 Subject: [PATCH 1/3] Fixes analyzer issue: Instance variable used while 'self' is not set matrixManager is assigned before self is set to [self init..] or [super init..] Moved assignment to after self = [super init...] --- src/Cocoa/MyOpenGLView.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Cocoa/MyOpenGLView.m b/src/Cocoa/MyOpenGLView.m index 9102fd2d8..0680c7f60 100644 --- a/src/Cocoa/MyOpenGLView.m +++ b/src/Cocoa/MyOpenGLView.m @@ -87,8 +87,6 @@ - (id) initWithFrame:(NSRect)frameRect } #endif - matrixManager = [[OOOpenGLMatrixManager alloc] init]; - // Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext NSOpenGLPixelFormatAttribute attrs[] = { @@ -137,6 +135,7 @@ - (id) initWithFrame:(NSRect)frameRect [self setWantsBestResolutionOpenGLSurface:YES]; } + matrixManager = [[OOOpenGLMatrixManager alloc] init]; _pixelFormatAttributes = [[NSData alloc] initWithBytes:attrs length:sizeof attrs]; virtualJoystickPosition = NSMakePoint(0.0,0.0); From c24bb8d9fe58833368299234e6b33dfc13642dc4 Mon Sep 17 00:00:00 2001 From: Job Bolle Date: Sun, 15 Oct 2017 18:37:29 +0200 Subject: [PATCH 2/3] Fixes analyzer issue: Access to instance variable results in null pointer dereference If error != NO_ERROR, we release and nillify self, then touch _source. Put subsequent code in else block. --- src/Core/OOALSoundChannel.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Core/OOALSoundChannel.m b/src/Core/OOALSoundChannel.m index e732b8262..38aaeae00 100644 --- a/src/Core/OOALSoundChannel.m +++ b/src/Core/OOALSoundChannel.m @@ -53,9 +53,12 @@ - (id) init [self release]; self = nil; } - // sources are all relative to listener, defaulting to zero vector - OOAL(alSourcei(_source, AL_SOURCE_RELATIVE, AL_TRUE)); - OOAL(alSource3f(_source, AL_POSITION, 0.0f, 0.0f, 0.0f)); + else + { + // sources are all relative to listener, defaulting to zero vector + OOAL(alSourcei(_source, AL_SOURCE_RELATIVE, AL_TRUE)); + OOAL(alSource3f(_source, AL_POSITION, 0.0f, 0.0f, 0.0f)); + } } return self; } From e0f311bb777167be7a20cef0f36890fdbec8d4a3 Mon Sep 17 00:00:00 2001 From: Job Bolle Date: Sun, 15 Oct 2017 18:38:55 +0200 Subject: [PATCH 3/3] Fixes analyzer issue: Access to instance variable results in null pointer dereference We test for (self == nil) indicating this is a possibility. Then we touch an instance variable regardless. Removed this line. If self == nil, this is a null pointer dereference; if not, standardMatrixUniformLocations is already nil. --- src/Core/Materials/OOShaderProgram.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Core/Materials/OOShaderProgram.m b/src/Core/Materials/OOShaderProgram.m index dfcb602a6..a8da65a45 100644 --- a/src/Core/Materials/OOShaderProgram.m +++ b/src/Core/Materials/OOShaderProgram.m @@ -304,8 +304,6 @@ - (id)initWithVertexShaderSource:(NSString *)vertexSource self = [super init]; if (self == nil) OK = NO; - standardMatrixUniformLocations = nil; - if (OK && vertexSource == nil && fragmentSource == nil) OK = NO; // Must have at least one shader! if (OK && prefixString != nil)