Fixed possible out of bound access + infinite loop in dirac header.