Add some error/overflow checks in codebook handling

Bug: 119120561
Test: manual
Change-Id: I2476ef29d81a8335fdcbdbbaa175a575138d4039
(cherry picked from commit b5e041da6bfe79b5ee5fb48374cd753df6d18015)
1 file changed