Commit 7b38b41b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

opengl: get gl value explicitly

(also fix unlikely ToCToU)
parent 2f952cf7
......@@ -799,7 +799,9 @@ static void ClearSurface(vout_display_t *vd)
if (sys->p_window->b_opaque)
{
/* Clear the surface to black with OpenGL ES 2 */
vlc_gl_t *gl = vlc_gl_Create(sys->embed, VLC_OPENGL_ES2, "$gles2");
char *modlist = var_InheritString(sys->embed, "gles2");
vlc_gl_t *gl = vlc_gl_Create(sys->embed, VLC_OPENGL_ES2, modlist);
free(modlist);
if (gl == NULL)
return;
......
......@@ -104,7 +104,7 @@ static int Open (vlc_object_t *obj)
goto error;
}
const char *gl_name = "$" MODULE_VARNAME;
char *gl_name = var_InheritString(surface, MODULE_VARNAME);
/* VDPAU GL interop works only with GLX. Override the "gl" option to force
* it. */
......@@ -118,10 +118,8 @@ static int Open (vlc_object_t *obj)
case VLC_CODEC_VDPAU_VIDEO_420:
{
/* Force the option only if it was not previously set */
char *str = var_InheritString(surface, MODULE_VARNAME);
if (str == NULL)
gl_name = "glx";
free(str);
if (gl_name == NULL)
gl_name = strdup("glx");
break;
}
default:
......@@ -131,6 +129,7 @@ static int Open (vlc_object_t *obj)
#endif
sys->gl = vlc_gl_Create (surface, API, gl_name);
free(gl_name);
if (sys->gl == NULL)
goto error;
......
......@@ -128,7 +128,9 @@ static int Open(vlc_object_t *object)
if (!surface)
goto error;
sys->gl = vlc_gl_Create (surface, VLC_OPENGL, "$gl");
char *modlist = var_InheritString(surface, "gl");
sys->gl = vlc_gl_Create (surface, VLC_OPENGL, modlist);
free(modlist);
if (!sys->gl)
{
vlc_object_release(surface);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment