aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-07-13 23:18:08 +0200
committerdec05eba <dec05eba@protonmail.com>2023-07-13 23:18:08 +0200
commit5ea469de363ab319f1cf0707c56bf31652877958 (patch)
treed5472fe6ceb49bbc9393b50cae0e076ab237fef6 /src
parent66ec83b862ea2a8dbda1c1f3663af88a8d12d9bc (diff)
Fix warning
Diffstat (limited to 'src')
-rw-r--r--src/HtmlParser.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/HtmlParser.c b/src/HtmlParser.c
index 31a5e70..709196e 100644
--- a/src/HtmlParser.c
+++ b/src/HtmlParser.c
@@ -71,18 +71,31 @@ static int is_newline(int c) {
static void lstrip(const char *str, size_t size, const char **output_str, size_t *output_size, int(*strip_filter_func)(int)) {
size_t i = 0;
+ if(size == 0) {
+ *output_str = str;
+ *output_size = size;
+ return;
+ }
+
while(i < size && strip_filter_func(str[i])) {
++i;
}
+
*output_str = str + i;
*output_size = size - i;
}
static void rstrip(const char *str, size_t size, size_t *output_size, int(*strip_filter_func)(int)) {
- long i = size - 1;
+ long i = (long)size - 1;
+ if(size == 0) {
+ *output_size = size;
+ return;
+ }
+
while(i >= 0 && strip_filter_func(str[i])) {
--i;
}
+
*output_size = i + 1;
}