lg->return_value = return_value;
- if (! lm_connection_close (lg->connection, &error))
- g_print ("An error occurred during lm_connection_close: %s\n",
- error->message);
-
- lm_connection_unref (lg->connection);
+ if (lg->connection)
+ {
+ if (! lm_connection_close (lg->connection, &error))
+ {
+ g_print ("An error occurred during lm_connection_close: %s\n",
+ error->message);
+ }
+ lm_connection_unref (lg->connection);
+ lg->connection = NULL;
+ }
g_main_loop_quit (lg->main_loop);
}