-
Notifications
You must be signed in to change notification settings - Fork 97
Description
The inner for loops in the following code should iterate over 0..#(len-1), not 0..#len:
Background: the peel function splits strings into left and right portions based on a delimiter. After the logic of finding the split point is all complete, this code copies the bytes of the left and right portions into their respective destination arrays. The leftLengths and rightLengths arrays are supplying the full lengths of the destination buffers, including the null byte, i.e. one greater than the actual length of the substring to be copied. Thus, when the code copies #len bytes from the source buffer, it is grabbing an extra byte from the source string and overwriting the destination's null terminator with it. This results in strings that are not null-terminated and misbehave in weird and hard-to-find ways.
As part of this issue, we should consider adding validation on the ak.Strings class that checks for null terminators, and/or a CI test that checks for null-terminators after a peel operation. I am hopeful that resolving this issue will also address the sporadic CI failures for peel/stick and allow us to move this from experimental to fully supported functionality.