Fix LREM count LONG_MIN overflow minor issue (#12465)

Limit the range of LREM count to -LONG_MAX ~ LONG_MAX.
Before the fix, passing -LONG_MAX would cause an overflow
and would effectively be the same as passing 0. (Because
this condition `toremove && removed == toremove `can never
be satisfied).

This is a minor fix as it shouldn't really affect users,
more like a cleanup.
This commit is contained in:
Binbin 2023-08-21 17:50:41 +08:00 committed by GitHub
parent 16988208bd
commit c98a28a848
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1060,7 +1060,7 @@ void lremCommand(client *c) {
long toremove;
long removed = 0;
if ((getLongFromObjectOrReply(c, c->argv[2], &toremove, NULL) != C_OK))
if (getRangeLongFromObjectOrReply(c, c->argv[2], -LONG_MAX, LONG_MAX, &toremove, NULL) != C_OK)
return;
subject = lookupKeyWriteOrReply(c,c->argv[1],shared.czero);