Closed Bug 565287 Opened 12 years ago Closed 12 years ago

GLContextProviderCGL potentially fails to load GL lib, based on uninitialized value

Categories

(Core :: Canvas: WebGL, defect)

All
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bjacob, Assigned: bjacob)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch Proposed patch (obsolete) — Splinter Review
Looking at the file gfx/thebes/src/GLContextProviderCGL.mm, in the class CGLLibrary:

class CGLLibrary
{
public:
    CGLLibrary() : mInitialized(PR_FALSE) {}

    PRBool EnsureInitialized()
    {
        if (mInitialized) {
            return PR_TRUE;
        }
        if (!mOGLLibrary) {
            mOGLLibrary = PR_LoadLibrary("/System/Library/Frameworks/OpenGL.framework/OpenGL");
            if (!mOGLLibrary) {
                NS_WARNING("Couldn't load OpenGL Framework.");
                return PR_FALSE;
            }
        }
        
        mInitialized = PR_TRUE;
        return PR_TRUE;
    }

private:
    PRBool mInitialized;
    PRLibrary *mOGLLibrary;
};


The mOGLLibrary pointer is apparently used uninitialized here, and seems to only be set inside of the if (!mOGLLibrary) { ... }. So if by accident it happens to hold a nonzero value, the OpenGL library won't be loaded.

Proposed patch initializes mOGLLibrary to nsnull.

Disclaimer 1: I don't know Objective C++.
Disclaimer 2: I don't have a mac to test. Didn't even test compilation.
Attachment #444863 - Attachment is obsolete: true
Attachment #444866 - Flags: review?(bas.schouten)
Attachment #444866 - Flags: review?(bas.schouten) → review+
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Assignee: nobody → bjacob
You need to log in before you can comment on or make changes to this bug.