1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-02 03:46:21 -04:00

Allocate the string of nodes being 'linkified'

This makes the string actually NUL terminated at the right place and the
matching will never go beyond the text region of the node. One example is
<!--http://elinks.cz/--> which didn't work before.
This commit is contained in:
Jonas Fonseca 2005-12-25 16:08:00 +01:00 committed by Jonas Fonseca
parent 2d020e4879
commit 5dd9061a55

View File

@ -430,6 +430,7 @@ render_dom_node_enhanced_text(struct dom_renderer *renderer, struct dom_node *no
unsigned char *string = node->string.string;
int length = node->string.length;
struct screen_char *template = &renderer->styles[node->type];
unsigned char *alloc_string;
if (check_dom_node_source(renderer, string, length)) {
render_dom_flush(renderer, string);
@ -437,6 +438,10 @@ render_dom_node_enhanced_text(struct dom_renderer *renderer, struct dom_node *no
assert_source(renderer, renderer->position, 0);
}
alloc_string = memacpy(string, length);
if (alloc_string)
string = alloc_string;
while (length > 0 && !regexec(regex, string, 1, &regmatch, 0)) {
int matchlen = regmatch.rm_eo - regmatch.rm_so;
int offset = regmatch.rm_so;
@ -458,6 +463,8 @@ render_dom_node_enhanced_text(struct dom_renderer *renderer, struct dom_node *no
if (length > 0)
render_dom_text(renderer, template, string, length);
mem_free_if(alloc_string);
}
#endif