| Summary: | SDL_GL_GetProcAddress returns NON-null pointer for invalid string | ||
|---|---|---|---|
| Product: | SDL | Reporter: | danhath |
| Component: | *don't know* | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 1.2.15 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | Prints invalid function pointer from SDL_GL_GetProcAddress | ||
Not a bug:
http://dri.freedesktop.org/wiki/glXGetProcAddressNeverReturnsNULL/
According to OpenGL, it is the application's responsibility to check for available extensions and only call the functions if they really exist. A non-NULL return from GetProcAddress() does not mean the function is safe to call.
We can't catch this in SDL, as a function name that's invalid today may become valid when a new extension is introduced tomorrow.
--ryan.
I see. Maybe the documentation for SDL_GL_GetProcAddress could be changed to read: "Returns a pointer to the named OpenGL function, or returns an undefined value if the function is not found". I didn't get burned by this b/c I was just playing around, but I can imagine newcomers not being aware of these misconceptions! Thanks for your trouble, -Dan (In reply to danhath from comment #2) > I see. Maybe the documentation for SDL_GL_GetProcAddress could be changed > to read: I've now updated the docs here... https://wiki.libsdl.org/SDL_GL_GetProcAddress ...it's actually a complicated and ugly subject, so it turned out to be a couple of paragraphs on how to navigate it. :) --ryan. |
Created attachment 1508 [details] Prints invalid function pointer from SDL_GL_GetProcAddress The function SDL_GL_GetProcAddress returns NON null function pointers for bogus strings. For example, SDL_GL_GetProcAddress("glThisIsNotAnOpenGLFunctionName") does NOT always return null. Even if this turns out to not be a problem with SDL but something SDL is using, I would think SDL should guard against this. An invalid function pointer is a disaster waiting to happen. This behavior makes me wonder what would happen with a valid OpenGL extension name that is unavailable on some machine. I have attached a small one file program to reproduce the bug (which happens on my machine). Thank you.