From 3ea078baf6e856258213dce22b5de53d0f22a6b4 Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" Date: Wed, 27 Mar 2024 11:49:20 +0100 Subject: [PATCH] - Fix for #1032, add safeguard to make table space positive. --- doc/Changelog | 1 + util/storage/lruhash.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/Changelog b/doc/Changelog index e8f1f1c39..1b73bf547 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -2,6 +2,7 @@ - Fix name of unit test for subnet cache response. - Fix #1032: The size of subnet_msg_cache calculation mistake cause memory usage increased beyond expectations. + - Fix for #1032, add safeguard to make table space positive. 25 March 2024: Yorgos - Merge #831 from Pierre4012: Improve Windows NSIS installer diff --git a/util/storage/lruhash.c b/util/storage/lruhash.c index 85bb8f02e..f14e83b56 100644 --- a/util/storage/lruhash.c +++ b/util/storage/lruhash.c @@ -543,7 +543,9 @@ lruhash_update_space_used(struct lruhash* table, void* cb_arg, int diff_size) /* find bin */ lock_quick_lock(&table->lock); - table->space_used = (size_t)((int)table->space_used + diff_size); + if((int)table->space_used + diff_size < 0) + table->space_used = 0; + else table->space_used = (size_t)((int)table->space_used + diff_size); if(table->space_used > table->space_max) reclaim_space(table, &reclaimlist); -- 2.47.3