h264: check buffer size before accessing it