From 3e01d0dc158358d091bdee0ddf90b0f0562e1c89 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 13 Jul 2023 23:20:38 +0200 Subject: Fix warning --- depends/html-parser | 2 +- src/HtmlSearch.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/depends/html-parser b/depends/html-parser index 66ec83b..5ea469d 160000 --- a/depends/html-parser +++ b/depends/html-parser @@ -1 +1 @@ -Subproject commit 66ec83b862ea2a8dbda1c1f3663af88a8d12d9bc +Subproject commit 5ea469de363ab319f1cf0707c56bf31652877958 diff --git a/src/HtmlSearch.c b/src/HtmlSearch.c index f1631a7..8449ac9 100644 --- a/src/HtmlSearch.c +++ b/src/HtmlSearch.c @@ -349,19 +349,32 @@ 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)) { + if(size == 0) { + *output_str = str; + *output_size = size; + return; + } + size_t i = 0; 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)) { + if(size == 0) { + *output_size = size; + return; + } + ssize_t i = size - 1; while(i >= 0 && strip_filter_func(str[i])) { --i; } + *output_size = i + 1; } -- cgit v1.2.3