diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2016-05-03 21:03:13 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2016-05-03 21:03:13 +0200 |
commit | 0ac5e3f0bef13c8b2d5f8f947100567aa4b13685 (patch) | |
tree | 399e5140b91eb08f048abb4d84a771ea52cfa5f0 /src | |
parent | 1709b7ddc6f0856be42640524f4e7fbff08035ac (diff) | |
download | fastd-0ac5e3f0bef13c8b2d5f8f947100567aa4b13685.tar fastd-0ac5e3f0bef13c8b2d5f8f947100567aa4b13685.zip |
vector: catch overflows of the alloc counter
Better fail than go into an endless loop...
Diffstat (limited to 'src')
-rw-r--r-- | src/vector.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/vector.c b/src/vector.c index aeeeebb..8cfecd4 100644 --- a/src/vector.c +++ b/src/vector.c @@ -57,8 +57,13 @@ void _fastd_vector_resize(fastd_vector_desc_t *desc, void **data, size_t n, size n = n*3/2; } - while (alloc < n) + while (alloc < n) { alloc <<= 1; + if (!alloc) { + errno = EOVERFLOW; + exit_errno("memory allocation error"); + } + } if (alloc != desc->allocated) { desc->allocated = alloc; |