Closed JEXcome closed 5 years ago
Hello there!
I found another source of crashes in updated 3.0.4 version. It is in XML.swift:37.
init(data: Data) { ensureLibXMLErrorHandlingSuppressed() guard data.count > 0 else { return } _document = data.withUnsafeBytes { (p: UnsafePointer<Int8>) -> htmlDocPtr in return xmlReadMemory(p, Int32(data.count), nil, nil, 0) // <- here } }
Seems like invalid xml response (for example, when processing browserconfig.xml) causes it.
You can reproduce this crash by downloadAll for URL:https://jex3.netlify.com
downloadAll
I fave fixed it this way:
init(data: Data) { ensureLibXMLErrorHandlingSuppressed() guard data.count > 0 else { return } var ptr : xmlDocPtr? = nil data.withUnsafeBytes { (p: UnsafePointer<Int8>) in ptr = xmlReadMemory(p, Int32(data.count), nil, nil, 0) } guard let p = ptr else { return } _document = p }
PS: same issue potentially can occur in HTML.swift
Thanks a lot @JEXcome, I have released 3.0.5 which should fix the XML and HTML potential crash.
3.0.5
Hello there!
I found another source of crashes in updated 3.0.4 version. It is in XML.swift:37.
Seems like invalid xml response (for example, when processing browserconfig.xml) causes it.
You can reproduce this crash by
downloadAll
for URL:https://jex3.netlify.comI fave fixed it this way:
PS: same issue potentially can occur in HTML.swift