summaryrefslogtreecommitdiffstats
path: root/src/remote-viewer-main.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2012-03-29 18:13:33 +0200
committerMarc-André Lureau <marcandre.lureau@gmail.com>2012-03-30 14:25:52 +0200
commitcc0696f46f99055c042b47f3a36477719dc2580d (patch)
tree515b3539cf69fddde975c47fdaa0c345d1a09cc1 /src/remote-viewer-main.c
parente2b41b43eb8477460ab6305fdabd7ca382d566d0 (diff)
downloadvirt-viewer-cc0696f46f99055c042b47f3a36477719dc2580d.tar.gz
virt-viewer-cc0696f46f99055c042b47f3a36477719dc2580d.tar.xz
virt-viewer-cc0696f46f99055c042b47f3a36477719dc2580d.zip
Fix recent --spice-controller regression, add error message
The current code will attempt to dereference args if --spice-controller, even if args is NULL. Let's not accept any extra argument/uri on the command line if using the controller. Beside, the conditionnal block looks better outside of the if condition.
Diffstat (limited to 'src/remote-viewer-main.c')
-rw-r--r--src/remote-viewer-main.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/remote-viewer-main.c b/src/remote-viewer-main.c
index f60edb6..64e0cbe 100644
--- a/src/remote-viewer-main.c
+++ b/src/remote-viewer-main.c
@@ -252,13 +252,20 @@ main(int argc, char **argv)
g_option_context_free(context);
- if ((!args || (g_strv_length(args) != 1))
#if HAVE_SPICE_GTK
- && !controller
+ if (controller) {
+ if (args) {
+ g_printerr(_("Error: extra arguments given while using Spice controller\n"));
+ goto cleanup;
+ }
+ } else
#endif
- ) {
+ if (!args || g_strv_length(args) == 0) {
if (connect_dialog(&uri) != 0)
goto cleanup;
+ } else if (g_strv_length(args) > 1) {
+ g_printerr(_("Error: can't handle multiple URIs\n"));
+ goto cleanup;
} else {
uri = g_strdup(args[0]);
}