]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/base64.cpp
fixed SetUserScale() calls to use correct scale on Y axis
[wxWidgets.git] / src / common / base64.cpp
index 2fb58c5b29e9d3e12e9b94fc3826caaadd7100e2..2832bffb3b8dc9c44fd042f5b56bde938abd4382 100644 (file)
@@ -118,7 +118,7 @@ wxBase64Decode(void *dst_, size_t dstLen,
     const char *p;
     for ( p = src; srcLen; p++, srcLen-- )
     {
-        const unsigned char c = decode[(int)*p]; // cast to suppress warnings
+        const unsigned char c = decode[wx_static_cast(unsigned char, *p)];
         switch ( c )
         {
             case WSP:
@@ -132,7 +132,7 @@ wxBase64Decode(void *dst_, size_t dstLen,
 
                 // force the loop to stop and an error to be returned
                 n = -1;
-                srcLen = 0;
+                srcLen = 1;
                 break;
 
             case PAD:
@@ -156,7 +156,7 @@ wxBase64Decode(void *dst_, size_t dstLen,
                 {
                     // force the loop terminate with an error
                     n = -1;
-                    srcLen = 0;
+                    srcLen = 1;
                 }
                 break;
 
@@ -165,7 +165,7 @@ wxBase64Decode(void *dst_, size_t dstLen,
                 {
                     // nothing is allowed after the end so provoke error return
                     n = -1;
-                    srcLen = 0;
+                    srcLen = 1;
                     break;
                 }
 
@@ -194,7 +194,11 @@ wxBase64Decode(void *dst_, size_t dstLen,
     if ( n )
     {
         if ( posErr )
-            *posErr = p - src;
+        {
+            // notice that the error was on a previous position as we did one
+            // extra "p++" in the loop line after it
+            *posErr = p - src - 1;
+        }
 
         return wxCONV_FAILED;
     }