Skip to content

Commit

Permalink
opengl: get gl value explicitly
Browse files Browse the repository at this point in the history
(also fix unlikely ToCToU)
  • Loading branch information
Rémi Denis-Courmont committed Jan 30, 2018
1 parent 2f952cf commit 7b38b41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion modules/video_output/android/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 4 additions & 5 deletions modules/video_output/opengl/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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:
Expand All @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion modules/video_output/win32/glwin32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7b38b41

Please sign in to comment.