mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Fix memory leak in the DOM configuration module
... by making the (only) user (which is the RSS renderer) responsible allocation of the dom_config structure.
This commit is contained in:
parent
ed17eb18df
commit
1bd98053b0
@ -1022,6 +1022,7 @@ render_dom_document(struct cache_entry *cached, struct document *document,
|
||||
{
|
||||
unsigned char *head = empty_string_or_(cached->head);
|
||||
struct dom_renderer renderer;
|
||||
struct dom_config config;
|
||||
struct conv_table *convert_table;
|
||||
struct sgml_parser *parser;
|
||||
enum sgml_parser_type parser_type;
|
||||
@ -1060,7 +1061,7 @@ render_dom_document(struct cache_entry *cached, struct document *document,
|
||||
} else if (renderer.doctype == SGML_DOCTYPE_RSS) {
|
||||
add_dom_stack_context(&parser->stack, &renderer,
|
||||
&dom_rss_renderer_context_info);
|
||||
add_dom_config_normalizer(&parser->stack, RSS_CONFIG_FLAGS);
|
||||
add_dom_config_normalizer(&parser->stack, &config, RSS_CONFIG_FLAGS);
|
||||
}
|
||||
|
||||
/* FIXME: When rendering this way we don't really care about the code.
|
||||
|
@ -224,7 +224,6 @@ dom_normalize_node_end(struct dom_stack *stack, struct dom_node *node, void *dat
|
||||
break;
|
||||
|
||||
case DOM_NODE_DOCUMENT:
|
||||
mem_free(config);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -285,20 +284,15 @@ static struct dom_stack_context_info dom_config_normalizer_context = {
|
||||
};
|
||||
|
||||
struct dom_config *
|
||||
add_dom_config_normalizer(struct dom_stack *stack, enum dom_config_flag flags)
|
||||
add_dom_config_normalizer(struct dom_stack *stack, struct dom_config *config,
|
||||
enum dom_config_flag flags)
|
||||
{
|
||||
struct dom_config *config;
|
||||
|
||||
config = mem_calloc(1, sizeof(*config));
|
||||
if (!config) return NULL;
|
||||
|
||||
memset(config, 0, sizeof(*config));
|
||||
config->flags = flags;
|
||||
|
||||
if (add_dom_stack_context(stack, config, &dom_config_normalizer_context))
|
||||
return config;
|
||||
|
||||
mem_free(config);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,8 @@ struct dom_config {
|
||||
};
|
||||
|
||||
struct dom_config *
|
||||
add_dom_config_normalizer(struct dom_stack *stack, enum dom_config_flag flags);
|
||||
add_dom_config_normalizer(struct dom_stack *stack, struct dom_config *config,
|
||||
enum dom_config_flag flags);
|
||||
|
||||
enum dom_config_flag
|
||||
parse_dom_config(unsigned char *flaglist, unsigned char separator);
|
||||
|
Loading…
Reference in New Issue
Block a user