Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addNextSibling() results in "pointer being freed was not allocated" #210

Open
1 of 5 tasks
AndroidGecko opened this issue Feb 26, 2019 · 1 comment
Open
1 of 5 tasks

Comments

@AndroidGecko
Copy link

AndroidGecko commented Feb 26, 2019

Description:

After using addNextSibling method. Application crashes during XMLDocument.deinit

deinit {
        xmlFreeDoc(self.docPtr)
    }

with malloc: *** error for object 0x7fee7f04465b: pointer being freed was not allocated

What I want to do?
I want to replace few nodes with new ones in xml.

How I am doing it?

if let doc = try? HTML(html: content, encoding: .utf8) {
    for media in doc.xpath("//replace-tag") {
                let img = "<img />"

                if let imgTag = try? XML(xml: img, encoding: .utf8) {
                    media.addNextSibling(imgTag.xpath("//img")[0])
                }
}

If I remove the addNextSibling method call, all works.
Before deallocating XMLDocument I can see that doc has properly attached img tags as in code.

Installation method:

  • Carthage
  • CocoaPods
  • Swift Package Manager
  • Manually
  • other: ()

Kanna version (or commit hash):

4.0.0

swift --version

4.2

Xcode version (optional):

10.1

@AndroidGecko
Copy link
Author

when building locally and removing

deinit {
        xmlFreeDoc(self.docPtr)
    }

all works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant