summaryrefslogtreecommitdiff
path: root/src/t_stream.c
diff options
context:
space:
mode:
authorzhaozhao.zz <zhaozhao.zz@alibaba-inc.com>2019-01-16 19:19:10 +0800
committerzhaozhao.zz <zhaozhao.zz@alibaba-inc.com>2019-01-16 19:19:14 +0800
commit645d44d545ec958b9f541d4b7473ec021331ab04 (patch)
tree4826f2937e482e0308ee368fa91c78ac4e9ba500 /src/t_stream.c
parent733438fe23f67559d4da922c749664ed5db5dfc9 (diff)
downloadredis-645d44d545ec958b9f541d4b7473ec021331ab04.tar.gz
Streams: checkType before XGROUP CREATE
Fix issue #5785, in case create group on a key is not stream.
Diffstat (limited to 'src/t_stream.c')
-rw-r--r--src/t_stream.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/t_stream.c b/src/t_stream.c
index 1a5acac42..9676e975e 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -1737,14 +1737,17 @@ NULL
/* Everything but the "HELP" option requires a key and group name. */
if (c->argc >= 4) {
o = lookupKeyWrite(c->db,c->argv[2]);
- if (o) s = o->ptr;
+ if (o) {
+ if (checkType(c,o,OBJ_STREAM)) return;
+ s = o->ptr;
+ }
grpname = c->argv[3]->ptr;
}
/* Check for missing key/group. */
if (c->argc >= 4 && !mkstream) {
/* At this point key must exist, or there is an error. */
- if (o == NULL) {
+ if (s == NULL) {
addReplyError(c,
"The XGROUP subcommand requires the key to exist. "
"Note that for CREATE you may want to use the MKSTREAM "
@@ -1752,8 +1755,6 @@ NULL
return;
}
- if (checkType(c,o,OBJ_STREAM)) return;
-
/* Certain subcommands require the group to exist. */
if ((cg = streamLookupCG(s,grpname)) == NULL &&
(!strcasecmp(opt,"SETID") ||
@@ -1781,7 +1782,8 @@ NULL
}
/* Handle the MKSTREAM option now that the command can no longer fail. */
- if (s == NULL && mkstream) {
+ if (s == NULL) {
+ serverAssert(mkstream);
o = createStreamObject();
dbAdd(c->db,c->argv[2],o);
s = o->ptr;