Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a couple of bugs uncovered by the Clang static analyzer #215

Merged
merged 2 commits into from
Jan 15, 2014

Conversation

haileys
Copy link
Contributor

@haileys haileys commented Jan 15, 2014

I ran the Clang static analyzer on a project I'm working on that uses hiredis and it found a couple of bugs.

There were three warnings, of which two are definitely legit. I have fixed these in the commits below.

The one warning I wasn't sure about was this one:

async.c:447:19: warning: The left operand of '!=' is a garbage value
        if (cb.fn != NULL) {
            ~~~~~ ^

This is in redisProcessCallbacks and it looks like it's triggerable when redisGetReply returns REDIS_OK but doesn't set reply to anything. I'm not familiar enough with the code to determine if this is possible though.

@pietern
Copy link
Contributor

pietern commented Jan 15, 2014

Looks good, thanks!

pietern added a commit that referenced this pull request Jan 15, 2014
Fix a couple of bugs uncovered by the Clang static analyzer
@pietern pietern merged commit 065e905 into redis:master Jan 15, 2014
@haileys haileys deleted the fix-bugs branch January 15, 2014 01:19
@pietern
Copy link
Contributor

pietern commented Jan 15, 2014

Btw, that cb is populated by this line:

hiredis/async.c

Line 419 in 070da21

if (__redisShiftCallback(&ac->replies,&cb) != REDIS_OK) {

@haileys
Copy link
Contributor Author

haileys commented Jan 15, 2014

@pietern Yep, although if the first call to redisGetReply doesn't read a full reply and we're in monitor mode, it looks like it may be possible that a garbage cb is pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants