Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
82b2bfd2
Commit
82b2bfd2
authored
Jun 12, 2020
by
antirez
Committed by
Oran Agra
Jul 20, 2020
Browse files
Fix LCS object type checking. Related to #7379.
(cherry picked from commit
10553988
)
parent
ec1faeec
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/t_string.c
View file @
82b2bfd2
...
...
@@ -516,13 +516,13 @@ void stralgoLCS(client *c) {
withmatchlen
=
1
;
}
else
if
(
!
strcasecmp
(
opt
,
"MINMATCHLEN"
)
&&
moreargs
)
{
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
j
+
1
],
&
minmatchlen
,
NULL
)
!=
C_OK
)
goto
clean
_
up
_obj
;
!=
C_OK
)
goto
cleanup
;
if
(
minmatchlen
<
0
)
minmatchlen
=
0
;
j
++
;
}
else
if
(
!
strcasecmp
(
opt
,
"STRINGS"
)
&&
moreargs
>
1
)
{
if
(
a
!=
NULL
)
{
addReplyError
(
c
,
"Either use STRINGS or KEYS"
);
goto
clean
_
up
_obj
;
goto
cleanup
;
}
a
=
c
->
argv
[
j
+
1
]
->
ptr
;
b
=
c
->
argv
[
j
+
2
]
->
ptr
;
...
...
@@ -530,13 +530,20 @@ void stralgoLCS(client *c) {
}
else
if
(
!
strcasecmp
(
opt
,
"KEYS"
)
&&
moreargs
>
1
)
{
if
(
a
!=
NULL
)
{
addReplyError
(
c
,
"Either use STRINGS or KEYS"
);
goto
clean
_
up
_obj
;
goto
cleanup
;
}
obja
=
lookupKeyRead
(
c
->
db
,
c
->
argv
[
j
+
1
]);
objb
=
lookupKeyRead
(
c
->
db
,
c
->
argv
[
j
+
2
]);
if
(
!
(
obja
->
type
==
OBJ_STRING
)
||
!
(
objb
->
type
==
OBJ_STRING
)
)
{
addReplyError
(
c
,
"Object associate with KEYS option should only be string type"
);
goto
clean_up_obj
;
if
((
obja
&&
obja
->
type
!=
OBJ_STRING
)
||
(
objb
&&
objb
->
type
!=
OBJ_STRING
))
{
addReplyError
(
c
,
"The specified keys must contain string values"
);
/* Don't cleanup the objects, we need to do that
* only after callign getDecodedObject(). */
obja
=
NULL
;
objb
=
NULL
;
goto
cleanup
;
}
obja
=
obja
?
getDecodedObject
(
obja
)
:
createStringObject
(
""
,
0
);
objb
=
objb
?
getDecodedObject
(
objb
)
:
createStringObject
(
""
,
0
);
...
...
@@ -545,7 +552,7 @@ void stralgoLCS(client *c) {
j
+=
2
;
}
else
{
addReply
(
c
,
shared
.
syntaxerr
);
goto
clean
_
up
_obj
;
goto
cleanup
;
}
}
...
...
@@ -553,12 +560,12 @@ void stralgoLCS(client *c) {
if
(
a
==
NULL
)
{
addReplyError
(
c
,
"Please specify two strings: "
"STRINGS or KEYS options are mandatory"
);
goto
clean
_
up
_obj
;
goto
cleanup
;
}
else
if
(
getlen
&&
getidx
)
{
addReplyError
(
c
,
"If you want both the length and indexes, please "
"just use IDX."
);
goto
clean
_
up
_obj
;
goto
cleanup
;
}
/* Compute the LCS using the vanilla dynamic programming technique of
...
...
@@ -696,7 +703,7 @@ void stralgoLCS(client *c) {
sdsfree
(
result
);
zfree
(
lcs
);
clean
_
up
_obj
:
cleanup:
if
(
obja
)
decrRefCount
(
obja
);
if
(
objb
)
decrRefCount
(
objb
);
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment