Added missing check for size of IndexBuffer