GNOME Bugzilla – Bug 702845
glshader element does not read shader file correctly
Last modified: 2013-06-27 23:12:01 UTC
in gstglfiltershader.c when reading shader file content, use incorrect variable to determine file size, leads none shader file read. and here's a quick fix fseek does not return file size, ftell does --- a/gst/gl/gstglfiltershader.c 2013-06-20 15:59:21.095105994 +0800 +++ b/gst/gl/gstglfiltershader.c 2013-06-20 17:03:45.969051269 +0800 @@ -259,6 +259,7 @@ size_t count; size_t bytes; + int seek_result; FILE *f; // read the filter from file @@ -274,7 +275,21 @@ *storage = 0; } - count = fseek (f, 0, SEEK_END); + seek_result = fseek (f, 0, SEEK_END); + + if (seek_result != 0){ + GST_ERROR ("could not seek file: %s", filename); + return -1; + } + + count = ftell (f); + + if (count == -1){ + GST_ERROR ("could not seek file: %s", filename); + return -1; + } + + *storage = g_malloc (count + 1); if (!*storage) { GST_ERROR ("g_malloc failed: %lud", (gulong) count);
Thanks, should be fixed by this as well hopefully: commit 8cbd495b5e71ef9a8604749e8c03190d6d314138 Author: Tim-Philipp Müller <tim@centricular.net> Date: Fri Jun 28 00:04:43 2013 +0100 glfiltershader: fix crash when loading shader file Just use g_file_get_contents() instead of home-made file loading. Fixes two issues - one is that we should pass "r" to fopen and not O_RDONLY, the other is that an incorrect variable was used to read the file length, leading to an empty shader file. Spotted by: Wang Xin-yu (王昕宇) <comicfans44@gmail.com> https://bugzilla.gnome.org/show_bug.cgi?id=702844 https://bugzilla.gnome.org/show_bug.cgi?id=702845 Conflicts: gst/gl/gstglfiltershader.c