This is an automated email from the ASF dual-hosted git repository.

hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin.git


The following commit(s) were added to refs/heads/master by this push:
     new b8c049a  fix: guard LRUCache against non-positive capacity (#1749)
b8c049a is described below

commit b8c049a251672902d8aeb1d0ccbc5cb9c352c0d6
Author: Nikolaus Schuetz <[email protected]>
AuthorDate: Thu Aug 20 23:42:12 2026 -0700

    fix: guard LRUCache against non-positive capacity (#1749)
---
 util/util.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/util/util.go b/util/util.go
index d4e0f27..71a9ade 100644
--- a/util/util.go
+++ b/util/util.go
@@ -391,6 +391,10 @@ func (cache *LRUCache) Get(key interface{}) (value 
interface{}, ok bool) {
 }
 
 func (cache *LRUCache) Put(key interface{}, value interface{}) {
+       if cache.capacity <= 0 {
+               return
+       }
+
        n, ok := cache.m[key]
        if ok {
                cache.remove(n, false)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to