1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[document] free text allocated by renderer2

This commit is contained in:
Witold Filipczyk 2021-07-18 13:35:31 +02:00
parent 4d6ae6e925
commit 8b76c1331d
3 changed files with 11 additions and 6 deletions

View File

@ -267,6 +267,7 @@ reset_document(struct document *document)
#ifdef CONFIG_ECMASCRIPT
free_string_list(&document->onload_snippets);
free_uri_list(&document->ecmascript_imports);
mem_free_set(&document->text, NULL);
/// kill_timer(&document->timeout);
/// free_document(document->dom);
#endif
@ -332,6 +333,7 @@ done_document(struct document *document)
free_string_list(&document->onload_snippets);
free_uri_list(&document->ecmascript_imports);
kill_timer(&document->timeout);
mem_free_if(document->text);
free_document(document->dom);
#endif

View File

@ -212,6 +212,7 @@ struct document {
timer_id_T timeout;
int ecmascript_counter;
void *dom;
char *text;
#endif
#ifdef CONFIG_CSS
/** @todo FIXME: We should externally maybe using cache_entry store the

View File

@ -281,16 +281,11 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str
}
struct string head;
struct string tt;
assert(cached && document);
if_assert_failed return;
if (!init_string(&head)) return;
if (!init_string(&tt)) {
done_string(&head);
return;
}
add_to_string(&head, "\r\nContent-Type: text/html; charset=utf-8\r\n");
@ -298,9 +293,16 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str
if (!buffer) {
std::string text = doc->write_to_string_formatted();
struct string tt;
if (!init_string(&tt)) {
done_string(&head);
return;
}
add_bytes_to_string(&tt, text.c_str(), text.size());
buffer = &tt;
document->text = tt.source;
}
mem_free_set(&cached->head, head.source);
render_html_document(cached, document, buffer);
}
}