From c728fd3b8dcd11fba5f4f9b8a4a25d4cfdf8c0eb Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Mon, 21 Apr 2014 09:47:08 +0100 Subject: [PATCH] gl: prevent division by 0 on unsupported texture type Coverity 1199697 --- gst-libs/gst/gl/gstglmemory.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c index 2dc2d8a..ed36aaa 100644 --- a/gst-libs/gst/gl/gstglmemory.c +++ b/gst-libs/gst/gl/gstglmemory.c @@ -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; -- 2.7.4