[xml] Potential memory leek in xmlCreateMemoryParserCtxt
- From: Martin Stoilov <mstoilov odesys com>
- To: xml gnome org
- Subject: [xml] Potential memory leek in xmlCreateMemoryParserCtxt
- Date: 18 Nov 2002 10:53:28 -0800
xmlParserCtxtPtr
xmlCreateMemoryParserCtxt(const char *buffer, int size) {
xmlParserCtxtPtr ctxt;
xmlParserInputPtr input;
xmlParserInputBufferPtr buf;
if (buffer == NULL)
return(NULL);
if (size <= 0)
return(NULL);
ctxt = xmlNewParserCtxt();
if (ctxt == NULL)
return(NULL);
buf = xmlParserInputBufferCreateMem(buffer, size,
XML_CHAR_ENCODING_NONE);
if (buf == NULL) return(NULL); /* <-------------- potential leek */
input = xmlNewInputStream(ctxt);
if (input == NULL) {
xmlFreeParserCtxt(ctxt);
return(NULL);
}
input->filename = NULL;
input->buf = buf;
input->base = input->buf->buffer->content;
input->cur = input->buf->buffer->content;
input->end = &input->buf->buffer->content[input->buf->buffer->use];
inputPush(ctxt, input);
return(ctxt);
}
I believe the line:
if (buf == NULL) return(NULL);
should look like:
if (buf == NULL) {
xmlFreeParserCtxt(ctxt);
return(NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]