examples/service-selection.c: Only free variable if success
authorJavier Jardón <jjardon@gnome.org>
Fri, 27 Jan 2012 18:41:21 +0000 (18:41 +0000)
committerJavier Jardón <jjardon@gnome.org>
Fri, 27 Jan 2012 18:42:42 +0000 (18:42 +0000)
Also print the error message in case there was an error

examples/service-selection.c

index b411e7a..f50d1dc 100644 (file)
@@ -24,14 +24,19 @@ int main (int argc, char *argv[])
                                      &subject_alt_name_constraint,
                                      &error);
 
-    if (success)
-        g_debug ("Got id: %s %s\n", nai, password);
+    if (success) {
+        printf ("Got identity: %s %s %s\n", nai, password, server_certificate_hash);
 
+        moonshot_free (nai);
+        moonshot_free (password);
+        moonshot_free (server_certificate_hash);
+        moonshot_free (ca_certificate);
+        moonshot_free (subject_name_constraint);
+        moonshot_free (subject_alt_name_constraint);
 
-    moonshot_free (nai);
-    moonshot_free (password);
-    moonshot_free (server_certificate_hash);
-    moonshot_free (ca_certificate);
-    moonshot_free (subject_name_constraint);
-    moonshot_free (subject_alt_name_constraint);
+        return 0;
+    } else {
+        printf ("Error: %s\n", error->message);
+        return 1;
+    }
 }