Procházet zdrojové kódy

x11display: fix loading cursor from compressed/encrypted stream

deflected před 7 roky
rodič
revize
eb0f753a3c
1 změnil soubory, kde provedl 7 přidání a 1 odebrání
  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";
     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;
   if (memcmp(magic, "Xcur", 4) == 0) {