Zap a double free.
[radsecproxy.git] / lib / radsec.c
index 45c4f42..ddd4edd 100644 (file)
@@ -1,4 +1,5 @@
-/* See the file COPYING for licensing information.  */
+/* Copyright 2010, 2011 NORDUnet A/S. All rights reserved.
+   See the file COPYING for licensing information.  */
 
 #if defined HAVE_CONFIG_H
 #include <config.h>
 #endif
 #include "rsp_debug.h"
 
+
+/* Public functions.  */
 int
-rs_context_create(struct rs_context **ctx, const char *dict)
+rs_context_create (struct rs_context **ctx, const char *dict)
 {
   int err = RSE_OK;
   struct rs_context *h;
@@ -114,18 +117,19 @@ _rs_peer_destroy (struct rs_peer *p)
   assert (p);
   assert (p->conn);
   assert (p->conn->ctx);
-  /* NOTE: The peer object doesn't own its connection (conn).  */
+
+  /* NOTE: The peer object doesn't own conn, nor realm.  */
+  /* NOTE: secret is owned by config */
   if (p->addr)
     {
       evutil_freeaddrinfo (p->addr);
       p->addr = NULL;
     }
-  if (p->secret)
-    rs_free (p->conn->ctx, p->secret);
   rs_free (p->conn->ctx, p);
 }
 
-void rs_context_destroy(struct rs_context *ctx)
+void
+rs_context_destroy (struct rs_context *ctx)
 {
   struct rs_realm *r = NULL;
   struct rs_peer *p = NULL;
@@ -142,13 +146,18 @@ void rs_context_destroy(struct rs_context *ctx)
       r = r->next;
       rs_free (ctx, tmp);
     }
-  dict_free ();
+
+  if (ctx->cfg)
+    cfg_free (ctx->cfg);
+  ctx->cfg = NULL;
+
   rs_free (ctx, ctx);
 }
 
-int rs_context_set_alloc_scheme(struct rs_context *ctx,
-                               struct rs_alloc_scheme *scheme)
+int
+rs_context_set_alloc_scheme (struct rs_context *ctx,
+                            struct rs_alloc_scheme *scheme)
 {
-  return rs_err_ctx_push_fl (ctx, RSE_NOSYS, __FILE__, __LINE__,
-                            "%s: NYI", __func__);
+  return rs_err_ctx_push_fl (ctx, RSE_NOSYS, __FILE__, __LINE__, NULL);
 }
+