Skip to content

Commit

Permalink
Merge pull request #93 from marshall-lee/fix_memory_corruption
Browse files Browse the repository at this point in the history
Fix incorrect list element comparator.
  • Loading branch information
Phillip Toland committed May 20, 2015
2 parents 1adc97b + 6213586 commit 241c213
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ext/patron/session_ext.c
Expand Up @@ -112,7 +112,7 @@ struct curl_state_list {
struct curl_state_list *next;
};

#define CS_LIST_COMPARATOR(p, _state_) (p->state == _state_)
#define CS_LIST_COMPARATOR(p, _state_) (p->state - _state_)

static struct curl_state_list *cs_list = NULL;

Expand All @@ -131,9 +131,9 @@ static void cs_list_remove(struct curl_state *state) {
struct curl_state_list *item = NULL;

assert(state != NULL);
SGLIB_LIST_FIND_MEMBER(struct curl_state_list, cs_list, state, CS_LIST_COMPARATOR, next, item);

SGLIB_LIST_DELETE_IF_MEMBER(struct curl_state_list, cs_list, state, CS_LIST_COMPARATOR, next, item);
if (item) {
SGLIB_LIST_DELETE(struct curl_state_list, cs_list, item, next);
ruby_xfree(item);
}
}
Expand Down

0 comments on commit 241c213

Please sign in to comment.