Skip to content

Error Domain=NSXMLParserErrorDomain Code=1 "(null)" on Linux when parsing larger amount of data #4851

@maciejtrybilo

Description

@maciejtrybilo

When parsing an XML file from Data, it appears that libxml2 fails to allocate memory and XMLParser.parse() fails.

This happens then the XMLParser is initialised with larger data:

let xmlParser = XMLParser(data: data)
let parseResult = xmlParser.parse() // returns false and NSXMLParserErrorDomain Code=1 is set

There is a workaround currently to use an input stream:

let inputStream = InputStream(data: data)
let xmlParser = XMLParser(inputStream: data)
let parseResult = xmlParser.parse() // works fine

However, the issue occurs only on Linux and the size of the data required to trigger this isn't unreasonable IMO. I can trigger it with data of around 930,000 bytes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions