[vlc-commits] opengl: get gl value explicitly
Rémi Denis-Courmont
git at videolan.org
Tue Jan 30 20:45:17 CET 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jan 30 21:19:45 2018 +0200| [7b38b41b1681b1691eb037e1f33da7773339aea1] | committer: Rémi Denis-Courmont
opengl: get gl value explicitly
(also fix unlikely ToCToU)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7b38b41b1681b1691eb037e1f33da7773339aea1
---
modules/video_output/android/display.c | 4 +++-
modules/video_output/opengl/display.c | 9 ++++-----
modules/video_output/win32/glwin32.c | 4 +++-
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index 1a68fad710..f7c71b4439 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -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;
diff --git a/modules/video_output/opengl/display.c b/modules/video_output/opengl/display.c
index a681760df2..b3bafa15c6 100644
--- a/modules/video_output/opengl/display.c
+++ b/modules/video_output/opengl/display.c
@@ -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;
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index 521270bad1..2d3debff6b 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -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);
More information about the vlc-commits
mailing list