mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05: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:
parent
2d020e4879
commit
5dd9061a55
@ -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, ®match, 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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user