Mtldebugdevice assertion, why?

Why is the following assetion thrown when trying to render a flat plygon from a set of vector positions.

-[MTLDebugDevice validateBufferArgs:options:]:467: Failed assertion Cannot create buffer of size zero

With this code?


extension SCNGeometry {
    static func multiPolygon (vertices: [SCNVector3]) -> SCNGeometry {
        var indices: [Int32] = [Int32(vertices.count)]
        indices.append(contentsOf: generateIndices(max: vertices.count))
        let pointer = UnsafePointer(indices)
        let vertexSource = SCNGeometrySource(vertices: vertices )
        let indexData = NSData(bytes: pointer,
                             length: indices.count * MemoryLayout<Int32>.size)
        let element = SCNGeometryElement(data: indexData as Data,
                                         primitiveType: .polygon,
                                         primitiveCount: 1,
                                         bytesPerIndex: MemoryLayout<Int32>.size)
        return SCNGeometry(sources: [vertexSource], elements: [element])
    }
    
    static private func generateIndices(max maxIndexValue: Int) -> [Int32]{
        var counter: Int = 0
        var output: [Int32] = []
        while counter < maxIndexValue {
            output.append(Int32(counter))
            counter += 1
        }
        return output
    }
}