Giter VIP home page Giter VIP logo

tfhpple's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tfhpple's Issues

xmlNodeGetContent memory leak, how to fix it

Hi,
We have code which does parsing of SOAP xml, and we use xmlNodeGetContent api. In valgrind it shows that it leaking memory. What i found in some posts that we need to explicitly free the memory returned by xmlNodeGetContent. Can someone help me on how to do this for below recursive calls?

void getSoapMsgDetails(xmlNode* node)
{
while(node)
{
if(XML_ELEMENT_NODE == node->type)
{
if(0 == strcmp( soapMsgHeader.c_str() ,(const char*)node->name ) )
{
xmlNode childNode=node->children;
while(childNode)
{
if( (XML_ELEMENT_NODE == childNode->type) && ( 0 == ( xmlChildElementCount(childNode) ) ) )
{
std::string name= (const char
)childNode->name;
std::string value = (const char*)xmlNodeGetContent(childNode);
soapHeaderAttributes.insert(std::pair< std::string, std::string> (name,value) );
}
childNode=childNode->next;
}
}

        if(0 == strcmp(soapMsgMo.c_str(), (const char*)node->name))
        {
            getSoapMsgMoList(node);
        }

        if(0 == strcmp(soapMsgBody.c_str(), (const char*)node->name))
        {
            node = node->children;
            while(XML_ELEMENT_NODE != node->type)
            {
                node = node->next;
            }
            msgTypeVal = (char*)node->name;
            node = node->parent;
        }
    }
    getSoapMsgDetails(node->children);
    node = node->next;
}

}

Memory Leak?

in XPathQuery.m line29
xmlChar *nodeContent = xmlNodeGetContent(currentNode);
this nodeContent seems to be leak in next code
if ([resultForNode[@"nodeName"] isEqual:@"text"] && parentResult) {
if this code is excuted the nodeContent is not free

Works on simulator, crash on real device...

First of all, I really like this library, you doing a great job thank you for maintaining it.
I have a serious problem, and its already one week i'm not able to solve it.
I'm calling on a method which does the following

 private class func getVideoAttribute(forKey key: String, source: String) -> Any? {
        let parser = TFHpple(htmlData: source.data(using: .utf8, allowLossyConversion: false))!
        **if let videos = parser.search(withXPathQuery: "//video")** // Crash happens here.

actually when going inside the error i can see it's crash on this line...

NSArray *PerformHTMLXPathQueryWithEncoding(NSData *document, NSString *query,NSString *encoding)
{
    xmlDocPtr doc;

    /* Load XML document */
    const char *encoded = encoding ? [encoding cStringUsingEncoding:NSUTF8StringEncoding] : NULL;
// Error happens herein the next line
    **doc = htmlReadMemory([document bytes], (int)[document length], "", encoded, HTML_PARSE_NOWARNING | 
    HTML_PARSE_NOERROR);**
    if (doc == NULL) {
        NSLog(@"Unable to parse.");
        return nil;
    }
    NSArray *result = PerformXPathQuery(doc, query);
    xmlFreeDoc(doc);
    return result;
}

any idea way it's happening only on real device ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.