diff --git a/core/vm/sp_vm_basecontext.cpp b/core/vm/sp_vm_basecontext.cpp index 29a53629..09a23017 100644 --- a/core/vm/sp_vm_basecontext.cpp +++ b/core/vm/sp_vm_basecontext.cpp @@ -542,7 +542,7 @@ inline int __CheckValidChar(char *c) int count; int bytecount = 0; - for(count=1; (*c & 0xC0) == 0x80; count++) + for (count=1; (*c & 0xC0) == 0x80; count++) { c--; } @@ -600,7 +600,7 @@ int BaseContext::StringToLocalUTF8(cell_t local_addr, size_t maxbytes, const cha } memcpy(dest, source, len); - if ((dest[len] & 1<<7) && needtocheck) + if ((dest[len-1] & 1<<7) && needtocheck) { len -= __CheckValidChar(dest+len-1); } diff --git a/sourcepawn/include/sp_vm_api.h b/sourcepawn/include/sp_vm_api.h index e4133cc7..73db0195 100644 --- a/sourcepawn/include/sp_vm_api.h +++ b/sourcepawn/include/sp_vm_api.h @@ -229,7 +229,7 @@ namespace SourcePawn * @param local_addr Local address in plugin. * @param maxbytes Number of bytes to write, including NULL terminator. * @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, size_t maxbytes,