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
7008a0ba
Commit
7008a0ba
authored
Jun 08, 2020
by
hwware
Browse files
fix memory leak
parent
2a05fa0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/t_string.c
View file @
7008a0ba
...
@@ -516,13 +516,13 @@ void stralgoLCS(client *c) {
...
@@ -516,13 +516,13 @@ void stralgoLCS(client *c) {
withmatchlen
=
1
;
withmatchlen
=
1
;
}
else
if
(
!
strcasecmp
(
opt
,
"MINMATCHLEN"
)
&&
moreargs
)
{
}
else
if
(
!
strcasecmp
(
opt
,
"MINMATCHLEN"
)
&&
moreargs
)
{
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
j
+
1
],
&
minmatchlen
,
NULL
)
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
j
+
1
],
&
minmatchlen
,
NULL
)
!=
C_OK
)
return
;
!=
C_OK
)
goto
clean_up_obj
;
if
(
minmatchlen
<
0
)
minmatchlen
=
0
;
if
(
minmatchlen
<
0
)
minmatchlen
=
0
;
j
++
;
j
++
;
}
else
if
(
!
strcasecmp
(
opt
,
"STRINGS"
)
&&
moreargs
>
1
)
{
}
else
if
(
!
strcasecmp
(
opt
,
"STRINGS"
)
&&
moreargs
>
1
)
{
if
(
a
!=
NULL
)
{
if
(
a
!=
NULL
)
{
addReplyError
(
c
,
"Either use STRINGS or KEYS"
);
addReplyError
(
c
,
"Either use STRINGS or KEYS"
);
return
;
goto
clean_up_obj
;
}
}
a
=
c
->
argv
[
j
+
1
]
->
ptr
;
a
=
c
->
argv
[
j
+
1
]
->
ptr
;
b
=
c
->
argv
[
j
+
2
]
->
ptr
;
b
=
c
->
argv
[
j
+
2
]
->
ptr
;
...
@@ -530,17 +530,14 @@ void stralgoLCS(client *c) {
...
@@ -530,17 +530,14 @@ void stralgoLCS(client *c) {
}
else
if
(
!
strcasecmp
(
opt
,
"KEYS"
)
&&
moreargs
>
1
)
{
}
else
if
(
!
strcasecmp
(
opt
,
"KEYS"
)
&&
moreargs
>
1
)
{
if
(
a
!=
NULL
)
{
if
(
a
!=
NULL
)
{
addReplyError
(
c
,
"Either use STRINGS or KEYS"
);
addReplyError
(
c
,
"Either use STRINGS or KEYS"
);
return
;
goto
clean_up_obj
;
}
}
obja
=
lookupKeyRead
(
c
->
db
,
c
->
argv
[
j
+
1
]);
obja
=
lookupKeyRead
(
c
->
db
,
c
->
argv
[
j
+
1
]);
objb
=
lookupKeyRead
(
c
->
db
,
c
->
argv
[
j
+
2
]);
objb
=
lookupKeyRead
(
c
->
db
,
c
->
argv
[
j
+
2
]);
if
(
!
(
obja
->
type
==
OBJ_STRING
)
||
!
(
objb
->
type
==
OBJ_STRING
)
)
{
if
(
!
(
obja
->
type
==
OBJ_STRING
)
||
!
(
objb
->
type
==
OBJ_STRING
)
)
{
addReplyError
(
c
,
"Object associate with KEYS option should only be string type"
);
addReplyError
(
c
,
"Object associate with KEYS option should only be string type"
);
return
;
goto
clean_up_obj
;
}
}
obja
=
obja
?
getDecodedObject
(
obja
)
:
createStringObject
(
""
,
0
);
obja
=
obja
?
getDecodedObject
(
obja
)
:
createStringObject
(
""
,
0
);
objb
=
objb
?
getDecodedObject
(
objb
)
:
createStringObject
(
""
,
0
);
objb
=
objb
?
getDecodedObject
(
objb
)
:
createStringObject
(
""
,
0
);
a
=
obja
->
ptr
;
a
=
obja
->
ptr
;
...
@@ -548,7 +545,7 @@ void stralgoLCS(client *c) {
...
@@ -548,7 +545,7 @@ void stralgoLCS(client *c) {
j
+=
2
;
j
+=
2
;
}
else
{
}
else
{
addReply
(
c
,
shared
.
syntaxerr
);
addReply
(
c
,
shared
.
syntaxerr
);
return
;
goto
clean_up_obj
;
}
}
}
}
...
@@ -556,12 +553,12 @@ void stralgoLCS(client *c) {
...
@@ -556,12 +553,12 @@ void stralgoLCS(client *c) {
if
(
a
==
NULL
)
{
if
(
a
==
NULL
)
{
addReplyError
(
c
,
"Please specify two strings: "
addReplyError
(
c
,
"Please specify two strings: "
"STRINGS or KEYS options are mandatory"
);
"STRINGS or KEYS options are mandatory"
);
return
;
goto
clean_up_obj
;
}
else
if
(
getlen
&&
getidx
)
{
}
else
if
(
getlen
&&
getidx
)
{
addReplyError
(
c
,
addReplyError
(
c
,
"If you want both the length and indexes, please "
"If you want both the length and indexes, please "
"just use IDX."
);
"just use IDX."
);
return
;
goto
clean_up_obj
;
}
}
/* Compute the LCS using the vanilla dynamic programming technique of
/* Compute the LCS using the vanilla dynamic programming technique of
...
@@ -696,10 +693,12 @@ void stralgoLCS(client *c) {
...
@@ -696,10 +693,12 @@ void stralgoLCS(client *c) {
}
}
/* Cleanup. */
/* Cleanup. */
if
(
obja
)
decrRefCount
(
obja
);
if
(
objb
)
decrRefCount
(
objb
);
sdsfree
(
result
);
sdsfree
(
result
);
zfree
(
lcs
);
zfree
(
lcs
);
clean_up_obj:
if
(
obja
)
decrRefCount
(
obja
);
if
(
objb
)
decrRefCount
(
objb
);
return
;
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