gl: prevent division by 0 on unsupported texture type
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 21 Apr 2014 08:47:08 +0000 (09:47 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:37 +0000 (19:31 +0000)
Coverity 1199697

gst-libs/gst/gl/gstglmemory.c

index 2dc2d8a1b01cb77cf1d2e9de44fd658eec564c31..ed36aaaeb526a3390f2c1b8f12a1bfcf3cbf7b69 100644 (file)
@@ -350,7 +350,11 @@ _calculate_unpack_length (GstGLMemory * gl_mem)
   gl_mem->unpack_length = 1;
 
   n_gl_bytes = _gl_texture_type_n_bytes (gl_mem->tex_type);
-
+  if (n_gl_bytes == 0) {
+    GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Unsupported texture type %d",
+        gl_mem->tex_type);
+    return;
+  }
 #if GST_GL_HAVE_OPENGL || GST_GL_HAVE_GLES3
   if (USING_OPENGL (gl_mem->context) || USING_GLES3 (gl_mem->context)) {
     gl_mem->unpack_length = gl_mem->stride / n_gl_bytes;