mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
add_html_to_string: If out of memory, roll back and return NULL.
This commit is contained in:
parent
8c9858b6a0
commit
14d79f6c91
@ -278,11 +278,18 @@ add_html_to_string(struct string *string, const unsigned char *src, int len)
|
|||||||
if (*src < 0x20 || *src >= 0x7F
|
if (*src < 0x20 || *src >= 0x7F
|
||||||
|| *src == '<' || *src == '>' || *src == '&'
|
|| *src == '<' || *src == '>' || *src == '&'
|
||||||
|| *src == '\"' || *src == '\'') {
|
|| *src == '\"' || *src == '\'') {
|
||||||
add_bytes_to_string(string, "&#", 2);
|
int rollback_length = string->length;
|
||||||
add_long_to_string(string, (long) *src);
|
|
||||||
add_char_to_string(string, ';');
|
if (!add_bytes_to_string(string, "&#", 2)
|
||||||
|
|| !add_long_to_string(string, (long) *src)
|
||||||
|
|| !add_char_to_string(string, ';')) {
|
||||||
|
string->length = rollback_length;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
add_char_to_string(string, *src);
|
if (!add_char_to_string(string, *src))
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user