Commit
7ef9d53e2e6dc53c44939ace7a9cad57c3aa00bf 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.
Related to #2138.
if (tok == NULL) {
tok = exnospace();
} else {
- strncpy(tok, str, sz + 1);
+ memcpy(tok, str, sz);
+ tok[sz] = '\0';
}
addItem (arr, v, tok);
v.integer++;