Fixed a pointer arithmetic issue that (very rarely) causes a segfault [ci skip]