Thursday, 9 January 2014

Memory leak in inputstream.c

If an unsupported encoding is passed to hubbub_parser_create(), libparserutils/src/input/inputstream.c will cause a memory leak because is does not free allocated objects before returning.

Here is a proposed fix, I hope you find the context in parserutils_inputstream_create():

if (enc != NULL) {
parserutils_filter_optparams params;

s->mibenum =
parserutils_charset_mibenum_from_name(enc, strlen(enc));

if (s->mibenum == 0) {
parserutils__filter_destroy(s->input); /* Added. */
parserutils_buffer_destroy(s->public.utf8); /* Added. */
parserutils_buffer_destroy(s->raw); /* Added. */
free(s); /* Added. */
return PARSERUTILS_BADENCODING;
}

params.encoding.name = enc;

Ralf

No comments:

Post a Comment