]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/imagpng.cpp
no, we shouldn't inconditionally add the separator at the end even if wxPATH_GET_SEPA...
[wxWidgets.git] / src / common / imagpng.cpp
index 9320f2f371911893fcffd07b9416f0501038c7f4..cfdf35d5fb5f269ab9bbf80c455459a6b3a1e190 100644 (file)
@@ -418,9 +418,12 @@ bool wxPNGHandler::DoCanRead( wxInputStream& stream )
 {
     unsigned char hdr[4];
 
-    stream.Read(hdr, 4);
-    stream.SeekI(-4, wxFromCurrent);
-    return (hdr[0] == 0x89 && hdr[1] == 'P' && hdr[2] == 'N' && hdr[3] == 'G');
+    if ( !stream.Read(hdr, WXSIZEOF(hdr)) )
+        return FALSE;
+
+    stream.SeekI(-WXSIZEOF(hdr), wxFromCurrent);
+
+    return memcmp(hdr, "\211PNG", WXSIZEOF(hdr)) == 0;
 }
 
 #endif  // wxUSE_STREAMS