Skip to content

Commit

Permalink
possibly fixes memory leak reported
Browse files Browse the repository at this point in the history
  • Loading branch information
taf2 committed Dec 14, 2015
1 parent 8749675 commit 50ab567
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ext/curb_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ rb_hash_clear_i(VALUE key, VALUE value, VALUE dummy) {
}

static void curl_multi_free(ruby_curl_multi *rbcm) {
VALUE hash = rbcm->requests;

if (rbcm && !rbcm->requests == Qnil && rb_type(rbcm->requests) == T_HASH && RHASH_SIZE(rbcm->requests) > 0) {
if (rbcm && !NIL_P(hash) && rb_type(hash) == T_HASH && RHASH_SIZE(hash) > 0) {

rb_hash_foreach( rbcm->requests, (int (*)())curl_multi_flush_easy, (VALUE)rbcm );
rb_hash_foreach(hash, (int (*)())curl_multi_flush_easy, (VALUE)rbcm);
rb_hash_foreach(hash, rb_hash_clear_i, 0);
/* rb_hash_clear(rbcm->requests); */

rb_hash_foreach(rbcm->requests, rb_hash_clear_i, 0); //rb_hash_clear(rbcm->requests);
rbcm->requests = Qnil;
}
curl_multi_cleanup(rbcm->handle);
Expand Down

0 comments on commit 50ab567

Please sign in to comment.