about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-08-24 21:30:18 +0200
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-08-24 21:30:18 +0200
commitc44b9d201765ab71ae0a7a741a396b28f289dce0 (patch)
treeb4d0cfe4abe8440ee416a31d5d227f2d71b0195c
parent2f9406fc55907e15abbe80d79e84c8e11ef07b60 (diff)
fix(index): use int for free_index
Prevents integer overflow and consequently segfaults the return value of
make_index is used directly.
-rw-r--r--index.c4
-rw-r--r--index.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/index.c b/index.c
index 71dd6cd..0a0ee67 100644
--- a/index.c
+++ b/index.c
@@ -122,9 +122,9 @@ int make_index(const char *blog_dir, char *script_name, bool get_text, struct en
     return index_count;
 }
 
-void free_index(struct entry *entries[], size_t count) {
+void free_index(struct entry *entries[], int count) {
     if(count > 0) {
-        for(size_t i = 0; i < count; i++) {
+        for(int i = 0; i < count; i++) {
             free_entry(*(*entries + i));
         }
     }
diff --git a/index.h b/index.h
index aad2fdc..586d203 100644
--- a/index.h
+++ b/index.h
@@ -33,4 +33,4 @@ int make_index(const char *blog_dir, char *script_name, bool get_text, struct en
  * @param entries pointer to array of entries
  * @param count size of the given array
  */
-void free_index(struct entry *entries[], size_t count);
+void free_index(struct entry *entries[], int count);