After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 702845 - glshader element does not read shader file correctly
glshader element does not read shader file correctly
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-gl
0.10.3
Other Windows
: Normal normal
: 0.10.4
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-06-22 02:38 UTC by comicfans44
Modified: 2013-06-27 23:12 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description comicfans44 2013-06-22 02:38:11 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);
Comment 1 Tim-Philipp Müller 2013-06-27 23:12:01 UTC
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