Don't double free in example code.
[radsecproxy.git] / lib / examples / client-blocking.c
index ef361e5..8d2b68d 100644 (file)
@@ -11,7 +11,7 @@
 #include "debug.h"             /* For rs_dump_packet().  */
 
 #define SECRET "sikrit"
-#define USER_NAME "molgan"
+#define USER_NAME "molgan@PROJECT-MOONSHOT.ORG"
 #define USER_PW "password"
 
 struct rs_error *
@@ -21,6 +21,7 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag)
   struct rs_connection *conn = NULL;
   struct rs_request *request = NULL;
   struct rs_packet *req = NULL, *resp = NULL;
+  struct rs_error *err = NULL;
 
   if (rs_context_create (&h, "/usr/share/freeradius/dictionary"))
     return NULL;
@@ -71,18 +72,15 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag)
     fprintf (stderr, "%s: no response\n", __func__);
 
  cleanup:
-  if (resp)
-    rs_packet_destroy (resp);
-  if (req)
-    rs_packet_destroy (req);
-  if (conn)
-    rs_conn_destroy (conn);
+  err = rs_err_conn_pop (conn);
   if (request)
     rs_request_destroy (request);
+  if (conn)
+    rs_conn_destroy (conn);
   if (h)
     rs_context_destroy (h);
 
-  return rs_err_conn_pop (conn);
+  return err;
 }
 
 int