michaelrsweet/mxml

LeakSanitizer: detected memory leaks

imanoracle opened this issue · 5 comments

==22843==ERROR: LeakSanitizer: detected memory leaks
There is a memory leak in MXML with the attached file.
leak.zip

Direct leak of 88 byte(s) in 1 object(s) allocated from:
    #0 0x548cfa  (/home/isharafa/temp/libfuzzer/testnew/mxml/a.out+0x548cfa)
    #1 0x7f8c7922d64f  (/usr/local/lib/libmxml.so.1+0x764f)

Indirect leak of 1 byte(s) in 1 object(s) allocated from:
    #0 0x5334a0  (/home/isharafa/temp/libfuzzer/testnew/mxml/a.out+0x5334a0)
    #1 0x7f8c7922d70e  (/usr/local/lib/libmxml.so.1+0x770e)

SUMMARY: AddressSanitizer: 89 byte(s) leaked in 2 allocation(s).
INFO: to ignore leaks on libFuzzer side use -detect_leaks=0.

MS: 3 InsertByte-CopyPart-InsertByte-; base unit: adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
0x3c,0xa,0xbf,0xa,0xbf,
<\x0a\xbf\x0a\xbf

Insufficient information.

It's easy to reproduce it. Compile the following file (with the attached file) with this command (to enable Address Sanitizer): clang++ -g -fsanitize=address mymxmltest.c -o xmlcmd -lmxml


#include <mxml.h>
int main(int argc, char* argv[])
{
	FILE *fp;
	mxml_node_t *tree;

	fp = fopen("leak-42d065436c49a2d380d6e3b86898a46b848c3608", "r");
	tree = mxmlLoadFile(NULL, fp, MXML_OPAQUE_CALLBACK);


    return 0;
}

The output of Address Santizier would be:

Direct leak of 88 byte(s) in 1 object(s) allocated from:
    #0 0x4c654a  (/home/isharafa/temp/libfuzzer/testnew/mxml/xmlcmd+0x4c654a)
    #1 0x7f05c616864f  (/usr/local/lib/libmxml.so.1+0x764f)

Indirect leak of 1 byte(s) in 1 object(s) allocated from:
    #0 0x4b0cf0  (/home/isharafa/temp/libfuzzer/testnew/mxml/xmlcmd+0x4b0cf0)
    #1 0x7f05c616870e  (/usr/local/lib/libmxml.so.1+0x770e)

SUMMARY: AddressSanitizer: 89 byte(s) leaked in 2 allocation(s).

@imanoracle Unless there is a memory leak reported if you call mxmlDelete(tree) before exiting the main function, this is not a bug. But if you are going to file a bug, you need to provide more details, not a ZIP file with a 5 byte junk file and a useless backtrace.

I have used mxmlDelete(tree) and still, there is a memory leak there.

#include <mxml.h>


int main(int argc, char* argv[])
{
	FILE *fp;
	mxml_node_t *tree;

	fp = fopen("leak-42d065436c49a2d380d6e3b86898a46b848c3608", "r");
	tree = mxmlLoadFile(NULL, fp, MXML_OPAQUE_CALLBACK);

        mxmlDelete(tree);
	fclose(fp);
    return 0;
}

Result (please enable your Address Sanitizer):

==12650==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 88 byte(s) in 1 object(s) allocated from:
    #0 0x4c659a  (/home/isharafa/temp/libfuzzer/testnew/mxml/xmlcmd+0x4c659a)
    #1 0x7ff4a8f3b64f  (/usr/local/lib/libmxml.so.1+0x764f)

Indirect leak of 1 byte(s) in 1 object(s) allocated from:
    #0 0x4b0d40  (/home/isharafa/temp/libfuzzer/testnew/mxml/xmlcmd+0x4b0d40)
    #1 0x7ff4a8f3b70e  (/usr/local/lib/libmxml.so.1+0x770e)

SUMMARY: AddressSanitizer: 89 byte(s) leaked in 2 allocation(s).

@michaelrsweet should we reopen this one?