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
hiredis
Commits
c96d4922
Unverified
Commit
c96d4922
authored
Dec 18, 2019
by
Michael Grunder
Committed by
GitHub
Dec 18, 2019
Browse files
Merge pull request #741 from redis/redisgetreply-null
Free the reply in redisGetReply when passed NULL
parents
b2d1ad64
ac0b186a
Changes
2
Hide whitespace changes
Inline
Side-by-side
hiredis.c
View file @
c96d4922
...
...
@@ -945,8 +945,13 @@ int redisGetReply(redisContext *c, void **reply) {
}
while
(
aux
==
NULL
);
}
/* Set reply object */
if
(
reply
!=
NULL
)
*
reply
=
aux
;
/* Set reply or free it if we were passed NULL */
if
(
reply
!=
NULL
)
{
*
reply
=
aux
;
}
else
{
freeReplyObject
(
aux
);
}
return
REDIS_OK
;
}
...
...
test.c
View file @
c96d4922
...
...
@@ -591,6 +591,11 @@ static void test_blocking_connection(struct config config) {
strcasecmp
(
reply
->
element
[
1
]
->
str
,
"pong"
)
==
0
);
freeReplyObject
(
reply
);
/* Make sure passing NULL to redisGetReply is safe */
test
(
"Can pass NULL to redisGetReply: "
);
assert
(
redisAppendCommand
(
c
,
"PING"
)
==
REDIS_OK
);
test_cond
(
redisGetReply
(
c
,
NULL
)
==
REDIS_OK
);
disconnect
(
c
,
0
);
}
...
...
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