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
5284d67e
Commit
5284d67e
authored
Mar 12, 2019
by
artix
Browse files
Redis Benchmark: fix possible usage of freed pointer (getRedisConfig)
Fixes issue #5912
parent
8fadebfc
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-benchmark.c
View file @
5284d67e
...
@@ -247,11 +247,11 @@ static redisConfig *getRedisConfig(const char *ip, int port,
...
@@ -247,11 +247,11 @@ static redisConfig *getRedisConfig(const char *ip, int port,
c
=
redisConnect
(
ip
,
port
);
c
=
redisConnect
(
ip
,
port
);
else
else
c
=
redisConnectUnix
(
hostsocket
);
c
=
redisConnectUnix
(
hostsocket
);
if
(
c
->
err
)
{
if
(
c
==
NULL
||
c
->
err
)
{
fprintf
(
stderr
,
"Could not connect to Redis at "
);
fprintf
(
stderr
,
"Could not connect to Redis at "
);
if
(
hostsocket
==
NULL
)
char
*
err
=
(
c
!=
NULL
?
c
->
errstr
:
""
);
fprintf
(
stderr
,
"%s:%d: %s
\n
"
,
ip
,
port
,
c
->
errst
r
);
if
(
hostsocket
==
NULL
)
fprintf
(
stderr
,
"%s:%d: %s
\n
"
,
ip
,
port
,
er
r
);
else
fprintf
(
stderr
,
"%s: %s
\n
"
,
hostsocket
,
c
->
errst
r
);
else
fprintf
(
stderr
,
"%s: %s
\n
"
,
hostsocket
,
er
r
);
goto
fail
;
goto
fail
;
}
}
redisAppendCommand
(
c
,
"CONFIG GET %s"
,
"save"
);
redisAppendCommand
(
c
,
"CONFIG GET %s"
,
"save"
);
...
@@ -276,18 +276,16 @@ static redisConfig *getRedisConfig(const char *ip, int port,
...
@@ -276,18 +276,16 @@ static redisConfig *getRedisConfig(const char *ip, int port,
case
1
:
cfg
->
appendonly
=
sdsnew
(
value
);
break
;
case
1
:
cfg
->
appendonly
=
sdsnew
(
value
);
break
;
}
}
}
}
if
(
reply
)
freeReplyObject
(
reply
);
freeReplyObject
(
reply
);
if
(
c
)
redisFree
(
c
);
redisFree
(
c
);
return
cfg
;
return
cfg
;
fail:
fail:
if
(
reply
)
freeReplyObject
(
reply
);
if
(
c
)
redisFree
(
c
);
zfree
(
cfg
);
fprintf
(
stderr
,
"ERROR: failed to fetch CONFIG from "
);
fprintf
(
stderr
,
"ERROR: failed to fetch CONFIG from "
);
if
(
c
->
connection_type
==
REDIS_CONN_TCP
)
if
(
hostsocket
==
NULL
)
fprintf
(
stderr
,
"%s:%d
\n
"
,
ip
,
port
);
fprintf
(
stderr
,
"%s:%d
\n
"
,
c
->
tcp
.
host
,
c
->
tcp
.
port
);
else
fprintf
(
stderr
,
"%s
\n
"
,
hostsocket
);
else
if
(
c
->
connection_type
==
REDIS_CONN_UNIX
)
freeReplyObject
(
reply
);
fprintf
(
stderr
,
"%s
\n
"
,
c
->
unix_sock
.
path
);
redisFree
(
c
);
zfree
(
cfg
);
return
NULL
;
return
NULL
;
}
}
static
void
freeRedisConfig
(
redisConfig
*
cfg
)
{
static
void
freeRedisConfig
(
redisConfig
*
cfg
)
{
...
...
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