Prevent segfault when buf index is negative.