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)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 21 Apr 2014 12:23:45 +0000 (13:23 +0100)
Coverity 1199697

gst-libs/gst/gl/gstglmemory.c

index 2dc2d8a..ed36aaa 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;