Yes, `next` can go beyond the limit, but not `curr`, on which the string is then split.  I've tried to make this more clear by a bit more of commenting, and non this occasion moved a `strlen()` call out of the loop and improved the adherence to the coding style guidelines.