[PATCH 2/2] xrandr: do not segfault when "--scale" or "--transform" have no output

Éric Piel eric.piel at tremplin-utc.net
Mon Oct 26 06:11:02 PDT 2009


"xrandr --scale 2x2" segfaults, because the --scale (and --transform)
options do not check for an existing output.

Make sure there is an output specified (like every other options).

Signed-off-by: Éric Piel <eric.piel at tremplin-utc.net>
---
 xrandr.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/xrandr.c b/xrandr.c
index 2d61978..eb23784 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -2157,7 +2157,6 @@ main (int argc, char **argv)
 	    if (++i>=argc) usage ();
 	    screen = check_strtol(argv[i]);
 	    if (screen < 0) usage();
-	    action_requested = True;
 	    continue;
 	}
 	if (!strcmp ("-q", argv[i]) || !strcmp ("--query", argv[i])) {
@@ -2368,6 +2367,7 @@ main (int argc, char **argv)
 	if (!strcmp ("--scale", argv[i]))
 	{
 	    double  sx, sy;
+	    if (!output) usage();
 	    if (++i>=argc) usage();
 	    if (sscanf (argv[i], "%lfx%lf", &sx, &sy) != 2)
 		usage ();
@@ -2387,6 +2387,7 @@ main (int argc, char **argv)
 	if (!strcmp ("--transform", argv[i])) {
 	    double  transform[3][3];
 	    int	    k, l;
+	    if (!output) usage();
 	    if (++i>=argc) usage ();
 	    init_transform (&output->transform);
 	    if (strcmp (argv[i], "none") != 0)
-- 
1.6.4.4


--------------040008070309030901030400--


More information about the xorg-devel mailing list