cezheng / Fuzi

A fast & lightweight XML & HTML parser in Swift with XPath & CSS support
MIT License
1.06k stars 151 forks source link

Warnings from Swift 5.2 compiler #106

Closed timbms closed 3 years ago

timbms commented 4 years ago

Description:

  1. In Document.swift
    public convenience init(cChars: [CChar]) throws {
    try self.init(buffer: UnsafeBufferPointer(start: UnsafePointer(cChars), count: cChars.count))
    }

    Initialization of 'UnsafePointer' (aka 'UnsafePointer') results in a dangling pointer

and also gives instructions on how to address:

  1. Implicit argument conversion from '[CChar]' (aka 'Array') to 'UnsafePointer' (aka 'UnsafePointer') produces a pointer valid only for the duration of the call to 'init(_:)'
  2. Use the 'withUnsafeBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope

Environment

How to reproduce:

Integrate project

cezheng commented 3 years ago

Thank you! Fixed in release 3.1.3.