diff
+ static int safe_multiply(long long a, long long b, long long *result) {
+     if (a > 0 && b > 0 && a > LLONG_MAX / b) return 0;
+     if (a < 0 && b < 0 && a < LLONG_MAX / b) return 0;
+     if (a > 0 && b < 0 && b < LLONG_MIN / a) return 0;
+     if (a < 0 && b > 0 && a < LLONG_MIN / b) return 0;
+     *result = a * b;
+     return 1;
+ }

  // ... (in the main function)
+ long long result;
+ if (!safe_multiply(bucketSize, 2, &result) || result > capacity) {
+     return RedisModule_ReplyWithError(ctx, "BUCKETSIZE is too large or would cause overflow");
+ }
- if (bucketSize * 2 > capacity) {
