OSDN Git Service

mesa: Don't leak shared state when context initialization fails
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 10 Apr 2013 14:47:08 +0000 (07:47 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 12 Apr 2013 23:24:48 +0000 (16:24 -0700)
Back up at line 1017 (not shown in patch), we add a reference to the
shared state.  Several places after that may divert to the error
handler, but, as far as I can tell, nothing ever unreferences the shared
state.

Fixes issue identified by Klocwork analysis:

    Resource acquired to 'shared->TexMutex' at line 1012 may be lost
    here. Also there is one similar error on line 1087.

NOTE: This is a candidate for the stable branches.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/context.c

index 0539934..939f896 100644 (file)
@@ -1080,6 +1080,7 @@ _mesa_initialize_context(struct gl_context *ctx,
    return GL_TRUE;
 
 fail:
+   _mesa_reference_shared_state(ctx, &ctx->Shared, NULL);
    free(ctx->BeginEnd);
    free(ctx->Exec);
    free(ctx->Save);