added unit tests for decoding invalid base64 strings; corrected bugs exposed by them

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51225 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-01-15 16:56:17 +00:00
parent 6167969572
commit 7bac0684f5
2 changed files with 42 additions and 4 deletions

View File

@@ -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;
}