This is the second half of a bug fix following the prior commit.
Commit
971293551421455a0d939b9f8cea17356b7968f8 refactored this code to avoid
the use of an SFIO buffer, inadvertently introducing a bug. The change did not
account for the source buffer not being NUL terminated. This fix wicks closer to
the original code, not assuming a NUL terminator and copying a known number of
bytes into the destination.
Fixes #2138.
## [Unreleased (2.49.3)]
+### Fixed
+
+- gvpr "split", "tokens", and "index" functions produce incorrect results #2138.
+ This was a regression that occurred between 2.47.1 and 2.47.2.
+
## [2.49.2] – 2021-10-16
### Changed
if (tok == NULL) {
tok = exnospace();
} else {
- strncpy(tok, str, sz + 1);
+ memcpy(tok, str, sz);
+ tok[sz] = '\0';
}
addItem (arr, v, tok);
v.integer++;
@pytest.mark.skipif(shutil.which("gvpr") is None,
reason="gvpr not available")
@pytest.mark.parametrize("examine", ("indices", "tokens"))
-@pytest.mark.xfail(strict=True)
def test_2138(examine: str):
"""
gvpr splitting and tokenizing should not result in trailing garbage