fixed StringToLocalUTF8 evaluating invalid chars

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40189
This commit is contained in:
Borja Ferrer 2006-11-12 13:13:12 +00:00
parent bad69571b6
commit 2943111703
2 changed files with 3 additions and 3 deletions

View File

@ -542,7 +542,7 @@ inline int __CheckValidChar(char *c)
int count; int count;
int bytecount = 0; int bytecount = 0;
for(count=1; (*c & 0xC0) == 0x80; count++) for (count=1; (*c & 0xC0) == 0x80; count++)
{ {
c--; c--;
} }
@ -600,7 +600,7 @@ int BaseContext::StringToLocalUTF8(cell_t local_addr, size_t maxbytes, const cha
} }
memcpy(dest, source, len); memcpy(dest, source, len);
if ((dest[len] & 1<<7) && needtocheck) if ((dest[len-1] & 1<<7) && needtocheck)
{ {
len -= __CheckValidChar(dest+len-1); len -= __CheckValidChar(dest+len-1);
} }

View File

@ -229,7 +229,7 @@ namespace SourcePawn
* @param local_addr Local address in plugin. * @param local_addr Local address in plugin.
* @param maxbytes Number of bytes to write, including NULL terminator. * @param maxbytes Number of bytes to write, including NULL terminator.
* @param source Source string to copy. * @param source Source string to copy.
* @param wrtnbytes Optionally set to the number of actual bytes written. * @param wrtnbytes Optionally set to the number of actual bytes written.
*/ */
virtual int StringToLocalUTF8(cell_t local_addr, virtual int StringToLocalUTF8(cell_t local_addr,
size_t maxbytes, size_t maxbytes,