[automerger] Add some error/overflow checks in codebook handling am: 6eb63e1192 am: bc4bde3bee am: 632704bab3 am: 9cea7b942e am: 57035e3928 am: 6d0e814689 am: 14cbdba347 am: c113668f32 am: efa0f5bc30
am: 8736c6e3b9

Change-Id: Ie6dd0e565dd7d2c3f71ebebb2c74a8c7b186f1a5