Unverified Commit efaf09ee authored by Madelyn Olson's avatar Madelyn Olson Committed by GitHub
Browse files

Flow through the error handling path for most errors (#8226)

Properly throw errors for invalid replication stream and support https://github.com/redis/redis/pull/8217
parent 55abd1c6
...@@ -1701,7 +1701,7 @@ void zaddGenericCommand(client *c, int flags) { ...@@ -1701,7 +1701,7 @@ void zaddGenericCommand(client *c, int flags) {
* we expect any number of score-element pairs. */ * we expect any number of score-element pairs. */
elements = c->argc-scoreidx; elements = c->argc-scoreidx;
if (elements % 2 || !elements) { if (elements % 2 || !elements) {
addReply(c,shared.syntaxerr); addReplyErrorObject(c,shared.syntaxerr);
return; return;
} }
elements /= 2; /* Now this holds the number of score-element pairs. */ elements /= 2; /* Now this holds the number of score-element pairs. */
...@@ -2525,7 +2525,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in ...@@ -2525,7 +2525,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in
/* test if the expected number of keys would overflow */ /* test if the expected number of keys would overflow */
if (setnum > (c->argc-(numkeysIndex+1))) { if (setnum > (c->argc-(numkeysIndex+1))) {
addReply(c,shared.syntaxerr); addReplyErrorObject(c,shared.syntaxerr);
return; return;
} }
...@@ -2536,7 +2536,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in ...@@ -2536,7 +2536,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in
if (obj != NULL) { if (obj != NULL) {
if (obj->type != OBJ_ZSET && obj->type != OBJ_SET) { if (obj->type != OBJ_ZSET && obj->type != OBJ_SET) {
zfree(src); zfree(src);
addReply(c,shared.wrongtypeerr); addReplyErrorObject(c,shared.wrongtypeerr);
return; return;
} }
...@@ -2582,7 +2582,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in ...@@ -2582,7 +2582,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in
aggregate = REDIS_AGGR_MAX; aggregate = REDIS_AGGR_MAX;
} else { } else {
zfree(src); zfree(src);
addReply(c,shared.syntaxerr); addReplyErrorObject(c,shared.syntaxerr);
return; return;
} }
j++; remaining--; j++; remaining--;
...@@ -2594,7 +2594,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in ...@@ -2594,7 +2594,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in
withscores = 1; withscores = 1;
} else { } else {
zfree(src); zfree(src);
addReply(c,shared.syntaxerr); addReplyErrorObject(c,shared.syntaxerr);
return; return;
} }
} }
...@@ -2793,7 +2793,7 @@ void zrangeGenericCommand(client *c, int reverse) { ...@@ -2793,7 +2793,7 @@ void zrangeGenericCommand(client *c, int reverse) {
if (c->argc == 5 && !strcasecmp(c->argv[4]->ptr,"withscores")) { if (c->argc == 5 && !strcasecmp(c->argv[4]->ptr,"withscores")) {
withscores = 1; withscores = 1;
} else if (c->argc >= 5) { } else if (c->argc >= 5) {
addReply(c,shared.syntaxerr); addReplyErrorObject(c,shared.syntaxerr);
return; return;
} }
...@@ -2938,7 +2938,7 @@ void genericZrangebyscoreCommand(client *c, int reverse) { ...@@ -2938,7 +2938,7 @@ void genericZrangebyscoreCommand(client *c, int reverse) {
} }
pos += 3; remaining -= 3; pos += 3; remaining -= 3;
} else { } else {
addReply(c,shared.syntaxerr); addReplyErrorObject(c,shared.syntaxerr);
return; return;
} }
} }
...@@ -3289,7 +3289,7 @@ void genericZrangebylexCommand(client *c, int reverse) { ...@@ -3289,7 +3289,7 @@ void genericZrangebylexCommand(client *c, int reverse) {
pos += 3; remaining -= 3; pos += 3; remaining -= 3;
} else { } else {
zslFreeLexRange(&range); zslFreeLexRange(&range);
addReply(c,shared.syntaxerr); addReplyErrorObject(c,shared.syntaxerr);
return; return;
} }
} }
...@@ -3632,7 +3632,7 @@ void genericZpopCommand(client *c, robj **keyv, int keyc, int where, int emitkey ...@@ -3632,7 +3632,7 @@ void genericZpopCommand(client *c, robj **keyv, int keyc, int where, int emitkey
/* ZPOPMIN key [<count>] */ /* ZPOPMIN key [<count>] */
void zpopminCommand(client *c) { void zpopminCommand(client *c) {
if (c->argc > 3) { if (c->argc > 3) {
addReply(c,shared.syntaxerr); addReplyErrorObject(c,shared.syntaxerr);
return; return;
} }
genericZpopCommand(c,&c->argv[1],1,ZSET_MIN,0, genericZpopCommand(c,&c->argv[1],1,ZSET_MIN,0,
...@@ -3642,7 +3642,7 @@ void zpopminCommand(client *c) { ...@@ -3642,7 +3642,7 @@ void zpopminCommand(client *c) {
/* ZMAXPOP key [<count>] */ /* ZMAXPOP key [<count>] */
void zpopmaxCommand(client *c) { void zpopmaxCommand(client *c) {
if (c->argc > 3) { if (c->argc > 3) {
addReply(c,shared.syntaxerr); addReplyErrorObject(c,shared.syntaxerr);
return; return;
} }
genericZpopCommand(c,&c->argv[1],1,ZSET_MAX,0, genericZpopCommand(c,&c->argv[1],1,ZSET_MAX,0,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment