Fix buffer overrun if idx is negative (it can be down to -23>>4), by prepending