scinfu / SwiftSoup

SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS)
https://scinfu.github.io/SwiftSoup/
MIT License
4.52k stars 345 forks source link

Fatal error: Attempted to read an unowned reference but object was already deallocated #205

Closed jwells89 closed 2 years ago

jwells89 commented 2 years ago

Hello,

With the latest release of SwiftSoup (2.3.7), I've been seeing crashes that didn't occur before. The crash occurs when selecting an element and wrapping it, as in this example:

if let quote = try? doc.select("blockquote") {
     _ = try? quote.wrap("<details ontoggle='postQuoteHeightChange()'></details>")
}

This yields the message Fatal error: Attempted to read an unowned reference but object 0x------------ was already deallocated, with Xcode showing a SIGABRT at line 470 of Node.swift: https://github.com/scinfu/SwiftSoup/blob/bc4350fc4dd520e92c10055ac1e2640238efb462/Sources/Node.swift#L470

The issue disappears if I roll SwiftSoup back to 2.3.6.

scinfu commented 2 years ago

Hi, yes it is the change that i do with 2.3.7. I make a rollback with 2.3.8 that is now online. I will fine a different solution for the other issue