Browse Source

x11display: fix loading cursor from compressed/encrypted stream

deflected 7 years ago
parent
commit
eb0f753a3c
1 changed files with 7 additions and 1 deletions
  1. 7 1
      panda/src/x11display/x11GraphicsWindow.cxx

+ 7 - 1
panda/src/x11display/x11GraphicsWindow.cxx

@@ -2193,7 +2193,13 @@ get_cursor(const Filename &filename) {
       << "Could not read from cursor file " << filename << "\n";
       << "Could not read from cursor file " << filename << "\n";
     return None;
     return None;
   }
   }
-  str->seekg(0, istream::beg);
+
+  // Put back the read bytes. Do not use seekg, because this will
+  // corrupt the stream if it points to encrypted/compressed file
+  str->putback(magic[3]);
+  str->putback(magic[2]);
+  str->putback(magic[1]);
+  str->putback(magic[0]);
 
 
   X11_Cursor h = None;
   X11_Cursor h = None;
   if (memcmp(magic, "Xcur", 4) == 0) {
   if (memcmp(magic, "Xcur", 4) == 0) {