diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-04-28 17:13:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-04-28 17:13:55 +0000 |
commit | 30082674cb0bb93bb8d636baef7d72fc7850bbdf (patch) | |
tree | 8ad9aa6039148337f2848528543f4322c0e92f9d /src | |
parent | 1797eb7bb919cbac8c7b77d3c5b7191feb0d8100 (diff) | |
download | gnunet-30082674cb0bb93bb8d636baef7d72fc7850bbdf.tar.gz gnunet-30082674cb0bb93bb8d636baef7d72fc7850bbdf.zip |
fixing leak
Diffstat (limited to 'src')
-rw-r--r-- | src/core/core_api.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index efb00c111..1d61cf96b 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -83,6 +83,11 @@ struct PeerRecord | |||
83 | void *pcic_cls; | 83 | void *pcic_cls; |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Pointer to free when we call pcic. | ||
87 | */ | ||
88 | void *pcic_ptr; | ||
89 | |||
90 | /** | ||
86 | * Request information ID for the given pcic (needed in case a | 91 | * Request information ID for the given pcic (needed in case a |
87 | * request is cancelled after being submitted to core and a new | 92 | * request is cancelled after being submitted to core and a new |
88 | * one is generated; in this case, we need to avoid matching the | 93 | * one is generated; in this case, we need to avoid matching the |
@@ -419,6 +424,8 @@ disconnect_and_free_peer_entry (void *cls, | |||
419 | if (NULL != (pcic = pr->pcic)) | 424 | if (NULL != (pcic = pr->pcic)) |
420 | { | 425 | { |
421 | pr->pcic = NULL; | 426 | pr->pcic = NULL; |
427 | GNUNET_free_non_null (pr->pcic_ptr); | ||
428 | pr->pcic_ptr = NULL; | ||
422 | pcic (pr->pcic_cls, | 429 | pcic (pr->pcic_cls, |
423 | &pr->peer, | 430 | &pr->peer, |
424 | zero, | 431 | zero, |
@@ -1250,6 +1257,8 @@ main_notify_handler (void *cls, | |||
1250 | } | 1257 | } |
1251 | pcic = pr->pcic; | 1258 | pcic = pr->pcic; |
1252 | pr->pcic = NULL; | 1259 | pr->pcic = NULL; |
1260 | GNUNET_free_non_null (pr->pcic_ptr); | ||
1261 | pr->pcic_ptr = NULL; | ||
1253 | if (pcic != NULL) | 1262 | if (pcic != NULL) |
1254 | pcic (pr->pcic_cls, | 1263 | pcic (pr->pcic_cls, |
1255 | &pr->peer, | 1264 | &pr->peer, |
@@ -1902,7 +1911,6 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h, | |||
1902 | irc = GNUNET_malloc (sizeof (struct GNUNET_CORE_InformationRequestContext)); | 1911 | irc = GNUNET_malloc (sizeof (struct GNUNET_CORE_InformationRequestContext)); |
1903 | irc->h = h; | 1912 | irc->h = h; |
1904 | irc->pr = pr; | 1913 | irc->pr = pr; |
1905 | // FIXME: who frees 'irc'? (if not cancelled?) | ||
1906 | cm = GNUNET_malloc (sizeof (struct ControlMessage) + | 1914 | cm = GNUNET_malloc (sizeof (struct ControlMessage) + |
1907 | sizeof (struct RequestInfoMessage)); | 1915 | sizeof (struct RequestInfoMessage)); |
1908 | cm->cont = &change_preference_send_continuation; | 1916 | cm->cont = &change_preference_send_continuation; |
@@ -1925,6 +1933,7 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h, | |||
1925 | cm); | 1933 | cm); |
1926 | pr->pcic = info; | 1934 | pr->pcic = info; |
1927 | pr->pcic_cls = info_cls; | 1935 | pr->pcic_cls = info_cls; |
1936 | pr->pcic_ptr = irc; /* for free'ing irc */ | ||
1928 | if (h->control_pending_head == cm) | 1937 | if (h->control_pending_head == cm) |
1929 | trigger_next_request (h, GNUNET_NO); | 1938 | trigger_next_request (h, GNUNET_NO); |
1930 | return irc; | 1939 | return irc; |
@@ -1948,6 +1957,7 @@ GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequest | |||
1948 | struct GNUNET_CORE_Handle *h = irc->h; | 1957 | struct GNUNET_CORE_Handle *h = irc->h; |
1949 | struct PeerRecord *pr = irc->pr; | 1958 | struct PeerRecord *pr = irc->pr; |
1950 | 1959 | ||
1960 | GNUNET_assert (pr->pcic_ptr == irc); | ||
1951 | if (irc->cm != NULL) | 1961 | if (irc->cm != NULL) |
1952 | { | 1962 | { |
1953 | GNUNET_CONTAINER_DLL_remove (h->control_pending_head, | 1963 | GNUNET_CONTAINER_DLL_remove (h->control_pending_head, |
@@ -1957,6 +1967,7 @@ GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequest | |||
1957 | } | 1967 | } |
1958 | pr->pcic = NULL; | 1968 | pr->pcic = NULL; |
1959 | pr->pcic_cls = NULL; | 1969 | pr->pcic_cls = NULL; |
1970 | pr->pcic_ptr = NULL; | ||
1960 | GNUNET_free (irc); | 1971 | GNUNET_free (irc); |
1961 | } | 1972 | } |
1962 | 1973 | ||