Add some error/overflow checks in codebook handling

Bug: 119120561
Test: manual
Change-Id: I2476ef29d81a8335fdcbdbbaa175a575138d4039
1 file changed