From 95ddefc056a11a44d9e753fd47a39db2c241e578 Mon Sep 17 00:00:00 2001 From: Yang Jun Date: Thu, 19 Mar 2026 21:20:57 +0800 Subject: [PATCH] fix: mem limiter for invalid ranges --- src/util/limiter.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/util/limiter.ts b/src/util/limiter.ts index 32c6c7815..f241f5e53 100644 --- a/src/util/limiter.ts +++ b/src/util/limiter.ts @@ -9,12 +9,14 @@ export class Limiter { this.limit = limit } use (count: number) { - count = +count || 0 - assert(this.base + count <= this.limit, this.message) - this.base += count + if (+count > 0) { + assert(this.base + +count <= this.limit, this.message) + this.base += +count + } } check (count: number) { - count = +count || 0 - assert(count <= this.limit, this.message) + if (+count > 0) { + assert(+count <= this.limit, this.message) + } } }