]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed bug with seeking beyond the end in wxStringInputStream::OnSysSeek() triggered...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 19 Sep 2004 21:49:41 +0000 (21:49 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 19 Sep 2004 21:49:41 +0000 (21:49 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29225 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/sstream.cpp

index 7ceedb65b59db5aecc3e37edb92698e7069deac5..de3496327e3192dad12f5297fd1c1e24a20d547b 100644 (file)
@@ -38,6 +38,8 @@
 
 off_t wxStringInputStream::OnSysSeek(off_t ofs, wxSeekMode mode)
 {
+    const size_t ofsMax = m_str.length()*sizeof(wxChar);
+
     switch ( mode )
     {
         case wxFromStart:
@@ -45,7 +47,7 @@ off_t wxStringInputStream::OnSysSeek(off_t ofs, wxSeekMode mode)
             break;
 
         case wxFromEnd:
-            ofs += m_str.length()*sizeof(wxChar);
+            ofs += ofsMax;
             break;
 
         case wxFromCurrent:
@@ -57,6 +59,9 @@ off_t wxStringInputStream::OnSysSeek(off_t ofs, wxSeekMode mode)
             return wxInvalidOffset;
     }
 
+    if ( ofs < 0 || wx_static_cast(size_t, ofs) >= ofsMax )
+        return wxInvalidOffset;
+
     m_pos = wx_static_cast(size_t, ofs);
 
     return ofs;