ac3: detect dba errors and prevent writing past end of array