]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix for #1032, add safeguard to make table space positive.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 27 Mar 2024 10:49:20 +0000 (11:49 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 27 Mar 2024 10:49:20 +0000 (11:49 +0100)
doc/Changelog
util/storage/lruhash.c

index e8f1f1c3912dfbeae53af58b8ee627d3434c2051..1b73bf547b6e397b6a892e7e62c47fe9895702fa 100644 (file)
@@ -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
index 85bb8f02ec736f1989c2d75a011c25079d95ba3a..f14e83b562cbe3427900ac10abd84f70112cf060 100644 (file)
@@ -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);