From 74427b94fcf53b3a3c4c87b26051a55c69aac093 Mon Sep 17 00:00:00 2001 From: Martin Pärtel Date: Wed, 26 Jun 2019 11:41:46 +0300 Subject: Resolve symlinks in readdir() so correct attributes are returned. Fixes #76 --- src/misc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/misc.c') diff --git a/src/misc.c b/src/misc.c index eae81f0..dafebed 100644 --- a/src/misc.c +++ b/src/misc.c @@ -188,10 +188,16 @@ void grow_memory_block(struct memory_block *a, int amount) a->size += amount; if (a->size >= a->capacity) { new_cap = a->capacity; - if (new_cap == 0) { - new_cap = 8; - } else { - new_cap *= 2; + while (new_cap < a->size) { + if (new_cap == 0) { + new_cap = 8; + } else { + 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; -- cgit v1.2.3