diff --git a/ion/include/ion/unicode/utf8_helper.h b/ion/include/ion/unicode/utf8_helper.h index a0abfcc04..3a6eb9a00 100644 --- a/ion/include/ion/unicode/utf8_helper.h +++ b/ion/include/ion/unicode/utf8_helper.h @@ -24,7 +24,7 @@ void CopyAndRemoveCodePoint(char * dst, size_t dstSize, const char * src, CodePo /* Remove all code points c. and update an index that should be lower if code * points where removed before it. Ensure null-termination of dst. */ -void RemoveCodePoint(char * buffer, CodePoint c, const char * * indexToDUpdate = nullptr, const char * stoppingPosition = nullptr); +void RemoveCodePoint(char * buffer, CodePoint c, const char * * indexToUpdate = nullptr, const char * stoppingPosition = nullptr); /* Copy src into dst until end of dst or code point c, with null termination. Return the length of the copy */ size_t CopyUntilCodePoint(char * dst, size_t dstSize, const char * src, CodePoint c); diff --git a/ion/src/shared/unicode/utf8_helper.cpp b/ion/src/shared/unicode/utf8_helper.cpp index 5a9e66c16..9f9537bb1 100644 --- a/ion/src/shared/unicode/utf8_helper.cpp +++ b/ion/src/shared/unicode/utf8_helper.cpp @@ -119,6 +119,7 @@ void RemoveCodePoint(char * buffer, CodePoint c, const char * * pointerToUpdate, UTF8Decoder decoder(buffer); const char * currentPointer = buffer; CodePoint codePoint = decoder.nextCodePoint(); + const char * initialPointerToUpdate = *pointerToUpdate; const char * nextPointer = decoder.stringPosition(); size_t bufferIndex = 0; size_t codePointCharSize = UTF8Decoder::CharSizeOfCodePoint(c); @@ -128,7 +129,7 @@ void RemoveCodePoint(char * buffer, CodePoint c, const char * * pointerToUpdate, int copySize = nextPointer - currentPointer; memmove(buffer + bufferIndex, currentPointer, copySize); bufferIndex+= copySize; - } else if (pointerToUpdate != nullptr && currentPointer < *pointerToUpdate) { + } else if (pointerToUpdate != nullptr && currentPointer < initialPointerToUpdate) { assert(*pointerToUpdate - buffer >= codePointCharSize); *pointerToUpdate = *pointerToUpdate - codePointCharSize; }