Fix more pointer arithmetic undefined behavior.

Reported by Guilherme Gonçalves.

This resolves #166.