diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2023-11-19 21:47:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-19 21:47:34 +0200 |
commit | db61be1897ffe8f4d1a72bed62c8c892d06a1983 (patch) | |
tree | 55372b2fd05926de9c0c6c35acb0554b144ae107 /src/misc.c | |
parent | 1fdf240aec17b6525ee2ebc76152ea8109f83595 (diff) | |
parent | 1136f5bd18ce5b1657347dc26b0aa8e3153786ce (diff) | |
download | bindfs-db61be1897ffe8f4d1a72bed62c8c892d06a1983.tar.gz |
Merge pull request #148 from hartwork/fix-warnings
Fix compile warnings (including a serious one) + cover FUSE 2 in CI + add `-Wextra` to `configure.ac`
Diffstat (limited to 'src/misc.c')
-rw-r--r-- | src/misc.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -19,6 +19,7 @@ #include "misc.h" #include <stdarg.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -166,7 +167,7 @@ bool path_starts_with(const char *path, const char* prefix, size_t prefix_len) const char* path_part = path + (prefix_part - prefix); const char* path_slash = strchr(path_part, '/'); - size_t path_part_len = path_slash ? path_slash - path_part : path_len - (path_part - path); + size_t path_part_len = path_slash ? (size_t)(path_slash - path_part) : path_len - (path_part - path); return prefix_part_len == path_part_len; } @@ -328,12 +329,12 @@ void grow_memory_block(struct memory_block *a, size_t amount) if (new_cap == 0) { new_cap = 8; } else { + if (new_cap > SIZE_MAX / 2) { + fprintf(stderr, "Memory block too large."); + abort(); + } new_cap *= 2; } - if (new_cap < 0) { // Overflow - fprintf(stderr, "Memory block too large."); - abort(); - } } a->ptr = (char *)realloc(a->ptr, new_cap); a->capacity = new_cap; |