diff --git a/src/t_list.c b/src/t_list.c index 961f59ae4..f8ca27458 100644 --- a/src/t_list.c +++ b/src/t_list.c @@ -592,20 +592,14 @@ void lposCommand(client *c) { } } else if (!strcasecmp(opt,"COUNT") && moreargs) { j++; - if (getLongFromObjectOrReply(c, c->argv[j], &count, NULL) != C_OK) + if (getPositiveLongFromObjectOrReply(c, c->argv[j], &count, + "COUNT can't be negative") != C_OK) return; - if (count < 0) { - addReplyError(c,"COUNT can't be negative"); - return; - } } else if (!strcasecmp(opt,"MAXLEN") && moreargs) { j++; - if (getLongFromObjectOrReply(c, c->argv[j], &maxlen, NULL) != C_OK) + if (getPositiveLongFromObjectOrReply(c, c->argv[j], &maxlen, + "MAXLEN can't be negative") != C_OK) return; - if (maxlen < 0) { - addReplyError(c,"MAXLEN can't be negative"); - return; - } } else { addReplyErrorObject(c,shared.syntaxerr); return;