[xml] Re : htmlParseReference leak





Hello,

It is seems this is a regression problem.

In the libxml2-2.5.11, the instruction
xmlFreeName
was correctly defined in htmlParseReference (HTMLparser.c)
But (at leat) from libxml2-2.7.2, this instruction has desappeared from htmlParseReference....


Stéphane Rubino


De : Stéphane Rubino <stephane rubino yahoo fr>
À : xml gnome org
Envoyé le : Jeudi, 17 Septembre 2009, 9h38mn 29s
Objet : [xml] htmlParseReference leak


Hello,


I'm currently using the libxml2 library.
It seems the htmlParseReference subroutine (implemented in HTMLparser.c file)
produces some leak.

The "name" parameter (localy defined in this subroutine),
does not seem to be desallocated.
==========(HTMLparser.c / htmlParseReference)==============
    ent = htmlParseEntityRef(ctxt, &name);
    if (name == NULL) {
        htmlCheckParagraph(ctxt);
        if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
            ctxt->sax->characters(ctxt->userData, BAD_CAST "&", 1);
        return;
    }
    if ((ent == NULL) || !(ent->value > 0)) {
        htmlCheckParagraph(ctxt);
        if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL)) {
        ctxt->sax->characters(ctxt->userData, BAD_CAST "&", 1);
        ctxt->sax->characters(ctxt->userData, name, xmlStrlen(name));
        /* ctxt->sax->characters(ctxt->userData, BAD_CAST ";", 1); */
        }
    } else {
        unsigned int c;
        int bits, i = 0;

        c = ent->value;
        if      (c <    0x80)
                { out[i++]= c;                bits= -6; }
        else if (c <   0x800)
                { out[i++]=((c >>  6) & 0x1F) | 0xC0;  bits=  0; }
        else if (c < 0x10000)
                { out[i++]=((c >> 12) & 0x0F) | 0xE0;  bits=  6; }
        else
                { out[i++]=((c >> 18) & 0x07) | 0xF0;  bits= 12; }

        for ( ; bits >= 0; bits-= 6) {
        out[i++]= ((c >> bits) & 0x3F) | 0x80;
        }
        out[i] = 0;

        htmlCheckParagraph(ctxt);
        if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
        ctxt->sax->characters(ctxt->userData, out, i);
    }
==============================================


If so, the    
   xmlFree(name);
instruction should be added.



Stéphane Rubino







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]