fix memory issues
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Tue, 4 Jun 2019 21:59:22 +0000 (23:59 +0200)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Tue, 4 Jun 2019 21:59:22 +0000 (23:59 +0200)
src/reclaim/gnunet-service-reclaim_tickets.c
src/reclaim/plugin_rest_openid_connect.c
src/reclaim/reclaim_api.c

index 9a595447d8bdc23265205e6ad1710f0ae64dbb71..182cb6186ec8adc344c64ef58c957fabe6609c25 100644 (file)
@@ -719,6 +719,7 @@ RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket,
                                                 rvk,
                                                 &revoke_attrs_cb,
                                                 rvk);
+  GNUNET_free (label);
   return rvk;
 }
 
index 912350248687955bef5ea58a464c06674ed218eb..03e037261abbb8901c76457e0198f946b43c2b11 100644 (file)
@@ -552,7 +552,6 @@ cleanup_handle (struct RequestHandle *handle)
     GNUNET_free (ego_tmp->keystring);
     GNUNET_free (ego_tmp);
   }
-  GNUNET_free_non_null (handle->attr_it);
   GNUNET_free (handle);
 }
 
@@ -871,7 +870,6 @@ oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
   char *code_string;
 
   handle->idp_op = NULL;
-  handle->ticket = *ticket;
   if (NULL == ticket)
   {
     handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_SERVER_ERROR);
@@ -879,6 +877,7 @@ oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
     GNUNET_SCHEDULER_add_now (&do_redirect_error, handle);
     return;
   }
+  handle->ticket = *ticket;
   ticket_str =
     GNUNET_STRINGS_data_to_string_alloc (&handle->ticket,
                                          sizeof (struct GNUNET_RECLAIM_Ticket));
@@ -1147,6 +1146,7 @@ lookup_redirect_uri_result (void *cls,
         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                     "Redirect uri %s contains client_id but is malformed\n",
                     tmp);
+        GNUNET_free (tmp);
         continue;
       }
       *pos = '\0';
@@ -1158,6 +1158,7 @@ lookup_redirect_uri_result (void *cls,
         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                     "Redirect uri %s contains client_id but is malformed\n",
                     tmp);
+        GNUNET_free (tmp);
         continue;
       }
       *pos = '\0';
@@ -1858,7 +1859,8 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
   // split header in "Bearer" and access_token
   authorization = GNUNET_strdup (authorization);
   authorization_type = strtok (authorization, delimiter);
-  if (0 != strcmp ("Bearer", authorization_type))
+  if ((NULL == authorization_type) ||
+      (0 != strcmp ("Bearer", authorization_type)))
   {
     handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_TOKEN);
     handle->edesc = GNUNET_strdup ("No Access Token");
@@ -1999,6 +2001,7 @@ list_ego (void *cls,
     init_cont (handle);
     return;
   }
+  GNUNET_assert (NULL != ego);
   if (ID_REST_STATE_INIT == handle->state)
   {
     ego_entry = GNUNET_new (struct EgoEntry);
@@ -2140,6 +2143,7 @@ libgnunet_plugin_rest_openid_connect_done (void *cls)
   while (GNUNET_YES ==
          GNUNET_CONTAINER_multihashmap_iterator_next (hashmap_it, NULL, value))
     GNUNET_free_non_null (value);
+  GNUNET_CONTAINER_multihashmap_iterator_destroy (hashmap_it);
   GNUNET_CONTAINER_multihashmap_destroy (OIDC_cookie_jar_map);
 
   hashmap_it =
index 5a9b9d4a9a273dde311cbbb17ef8de6b667774bc..b0bedfac5bb0a2bd4b245489f34765c08701c761 100644 (file)
@@ -505,12 +505,10 @@ handle_consume_ticket_result (void *cls,
           op->ar_cb (op->cls, &msg->identity, le->claim);
         GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs);
       }
-    }
-    if (NULL != op) {
       op->ar_cb (op->cls, NULL, NULL);
-      GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
-      free_op (op);
     }
+    GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
+    free_op (op);
     return;
   }
   GNUNET_assert (0);