[vlc-commits] [Git][videolan/vlc][master] 2 commits: opengl: check sampler failure

Romain Vimont (@rom1v) gitlab at videolan.org
Thu Sep 2 09:24:12 UTC 2021



Romain Vimont pushed to branch master at VideoLAN / VLC


Commits:
e3ffa4c2 by Romain Vimont at 2021-09-01T10:33:14+02:00
opengl: check sampler failure

On first call, vlc_gl_filter_GetSampler() may return NULL, so check the
return value.

- - - - -
021c73cd by Romain Vimont at 2021-09-01T10:33:14+02:00
opengl: reorder to simplify error handling

vlc_gl_filter_GetSampler() may fail (return NULL), but the caller need
not explicitly cleanup the returned sampler on success.

Therefore, retrieve the sampler as soon as possible to simplify error
handling.

- - - - -


4 changed files:

- modules/video_filter/deinterlace/glblend.c
- modules/video_output/opengl/filter_draw.c
- modules/video_output/opengl/filter_mock.c
- modules/video_output/opengl/renderer.c


Changes:

=====================================
modules/video_filter/deinterlace/glblend.c
=====================================
@@ -90,10 +90,6 @@ Open(struct vlc_gl_filter *filter, const config_chain_t *config,
     (void) config;
     (void) size_out;
 
-    struct sys *sys = filter->sys = malloc(sizeof(*sys));
-    if (!sys)
-        return VLC_EGENERIC;
-
     static const struct vlc_gl_filter_ops ops = {
         .draw = Draw,
         .close = Close,
@@ -102,6 +98,12 @@ Open(struct vlc_gl_filter *filter, const config_chain_t *config,
     filter->config.filter_planes = true;
 
     struct vlc_gl_sampler *sampler = vlc_gl_filter_GetSampler(filter);
+    if (!sampler)
+        return VLC_EGENERIC;
+
+    struct sys *sys = filter->sys = malloc(sizeof(*sys));
+    if (!sys)
+        return VLC_EGENERIC;
 
     static const char *const VERTEX_SHADER =
         "attribute vec2 vertex_pos;\n"


=====================================
modules/video_output/opengl/filter_draw.c
=====================================
@@ -94,12 +94,14 @@ Open(struct vlc_gl_filter *filter, const config_chain_t *config,
 {
     (void) size_out;
 
+    struct vlc_gl_sampler *sampler = vlc_gl_filter_GetSampler(filter);
+    if (!sampler)
+        return VLC_EGENERIC;
+
     struct sys *sys = filter->sys = malloc(sizeof(*sys));
     if (!sys)
         return VLC_EGENERIC;
 
-    struct vlc_gl_sampler *sampler = vlc_gl_filter_GetSampler(filter);
-
     static const char *const VERTEX_SHADER_BODY =
         "attribute vec2 vertex_pos;\n"
         "varying vec2 tex_coords;\n"


=====================================
modules/video_output/opengl/filter_mock.c
=====================================
@@ -327,6 +327,8 @@ InitMask(struct vlc_gl_filter *filter)
     const opengl_vtable_t *vt = &filter->api->vt;
 
     struct vlc_gl_sampler *sampler = vlc_gl_filter_GetSampler(filter);
+    if (!sampler)
+        return VLC_EGENERIC;
 
     static const char *const VERTEX_SHADER_BODY =
         "attribute vec2 vertex_pos;\n"
@@ -425,6 +427,8 @@ InitPlane(struct vlc_gl_filter *filter)
     filter->config.filter_planes = true;
 
     struct vlc_gl_sampler *sampler = vlc_gl_filter_GetSampler(filter);
+    if (!sampler)
+        return VLC_EGENERIC;
 
     static const char *const VERTEX_SHADER_BODY =
         "attribute vec2 vertex_pos;\n"


=====================================
modules/video_output/opengl/renderer.c
=====================================
@@ -315,6 +315,10 @@ vlc_gl_renderer_Open(struct vlc_gl_filter *filter,
 
     const opengl_vtable_t *vt = &filter->api->vt;
 
+    struct vlc_gl_sampler *sampler = vlc_gl_filter_GetSampler(filter);
+    if (!sampler)
+        return VLC_EGENERIC;
+
     struct vlc_gl_renderer *renderer = calloc(1, sizeof(*renderer));
     if (!renderer)
         return VLC_EGENERIC;
@@ -326,7 +330,6 @@ vlc_gl_renderer_Open(struct vlc_gl_filter *filter,
     filter->ops = &filter_ops;
     filter->sys = renderer;
 
-    struct vlc_gl_sampler *sampler = vlc_gl_filter_GetSampler(filter);
     renderer->sampler = sampler;
 
     renderer->api = filter->api;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e1c7694d75ab57cd66b4bb96f22862025ef6f00e...021c73cdb22aed34fd6d295dce388049f69a538f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e1c7694d75ab57cd66b4bb96f22862025ef6f00e...021c73cdb22aed34fd6d295dce388049f69a538f
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list