Add missing comment for the offset argument of tokenize. Add error checko on the offset.

This commit is contained in:
Enrico Fraccaroli (Galfurian)
2024-02-29 11:06:04 -05:00
parent ed7454f1e0
commit d213276817
4 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -221,7 +221,7 @@ char *strpbrk(const char *string, const char *control)
int tokenize(const char *string, char *separators, size_t *offset, char *buffer, ssize_t buflen)
{
// If we reached the end of the parsed string, stop.
if (string[*offset] == 0) {
if ((*offset >= buflen) || (string[*offset] == 0)) {
return 0;
}
// Keep copying character until we either reach 1) the end of the buffer, 2) a