Fix a possible out of range access in previous patch