aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-07-03 18:19:05 +0200
committerdec05eba <dec05eba@protonmail.com>2021-07-03 18:19:05 +0200
commitc545ae2d90170de11806393acda197a0ca43f488 (patch)
treeb3d11734e7cc7cb2c7f111a126ad52906e88d7d7 /src
parent8f41cc827b3c4096da4cd770175f43a085231bbf (diff)
Fix string_append incorrect allocation size
Diffstat (limited to 'src')
-rw-r--r--src/HtmlSearch.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/HtmlSearch.c b/src/HtmlSearch.c
index bc58881..d72055a 100644
--- a/src/HtmlSearch.c
+++ b/src/HtmlSearch.c
@@ -43,7 +43,10 @@ static int string_ensure_capacity(QuickMediaString *self, size_t new_capacity) {
}
static int string_append(QuickMediaString *self, const char *str, size_t size) {
- int res = string_ensure_capacity(self, self->size + size);
+ if(size == 0)
+ return 0;
+
+ int res = string_ensure_capacity(self, self->size + size + 1);
if(res != 0)
return res;
@@ -445,7 +448,7 @@ static int merge_inner_text(QuickMediaHtmlNode *node, QuickMediaString *str) {
const char *inner_text = node->name.data;
size_t inner_text_size = node->name.size;
strip(inner_text, inner_text_size, &inner_text, &inner_text_size, is_newline);
- if(inner_text_size > 0) {
+ if(inner_text_size > 0) { /* ignore empty text, but add the original text */
if(string_append(str, node->name.data, node->name.size) != 0)
return 1;
}