]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/zipstrm.cpp
wxMemoryDC constructor now optionally accepts a wxBitmap parameter,
[wxWidgets.git] / src / common / zipstrm.cpp
index 60284d99a17abc28d3d2755d1bed2884fd136cd3..6116b8e0c54fe2993986badb58f452813870c8cb 100644 (file)
@@ -87,6 +87,9 @@ wxFORCE_LINK_THIS_MODULE(zipstrm)
 //
 static wxString ReadString(wxInputStream& stream, wxUint16 len, wxMBConv& conv)
 {
+    if (len == 0)
+        return wxEmptyString;
+
 #if wxUSE_UNICODE
     wxCharBuffer buf(len);
     stream.Read(buf.data(), len);
@@ -758,7 +761,7 @@ wxString wxZipEntry::GetName(wxPathFormat format /*=wxPATH_NATIVE*/) const
         case wxPATH_DOS:
         {
             wxString name(isDir ? m_Name + _T("\\") : m_Name);
-            for (size_t i = name.length() - 1; i > 0; --i)
+            for (size_t i = 0; i < name.length(); i++)
                 if (name[i] == _T('/'))
                     name[i] = _T('\\');
             return name;
@@ -1614,22 +1617,20 @@ wxStreamError wxZipInputStream::ReadLocal(bool readEndRec /*=false*/)
         return wxSTREAM_EOF;
     }
 
-    if (m_signature != LOCAL_MAGIC) {
-        wxLogError(_("error reading zip local header"));
-        return wxSTREAM_READ_ERROR;
-    }
-
-    m_headerSize = m_entry.ReadLocal(*m_parent_i_stream, GetConv());
-    m_signature = 0;
-    m_entry.SetOffset(m_position);
-    m_entry.SetKey(m_position);
+    if (m_signature == LOCAL_MAGIC) {
+        m_headerSize = m_entry.ReadLocal(*m_parent_i_stream, GetConv());
+        m_signature = 0;
+        m_entry.SetOffset(m_position);
+        m_entry.SetKey(m_position);
 
-    if (!m_headerSize) {
-        return wxSTREAM_READ_ERROR;
-    } else {
-        m_TotalEntries++;
-        return wxSTREAM_NO_ERROR;
+        if (m_headerSize) {
+            m_TotalEntries++;
+            return wxSTREAM_NO_ERROR;
+        }
     }
+
+    wxLogError(_("error reading zip local header"));
+    return wxSTREAM_READ_ERROR;
 }
 
 wxUint32 wxZipInputStream::ReadSignature()