From 813191c8e9be42d5b113eb35242dc74f5088bddd Mon Sep 17 00:00:00 2001 From: Shawn Betts Date: Fri, 16 Apr 2010 17:36:03 -0700 Subject: in init_screen, properly handle a dot in the display string --- src/screen.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/screen.c b/src/screen.c index 3848e29..f26f036 100644 --- a/src/screen.c +++ b/src/screen.c @@ -239,6 +239,7 @@ init_screen (rp_screen *s, int screen_num) { XGCValues gcv; int xine_screen_num; + char *colon; /* We use screen_num below to refer to the real X screen number, but * if we're using Xinerama, it will only be the Xinerama logical screen @@ -276,16 +277,17 @@ init_screen (rp_screen *s, int screen_num) /* Build the display string for each screen */ s->display_string = xmalloc (strlen(DisplayString (dpy)) + 21); sprintf (s->display_string, "DISPLAY=%s", DisplayString (dpy)); - if (strrchr (DisplayString (dpy), ':')) + colon = strrchr (DisplayString (dpy), ':'); + if (colon) { char *dot; dot = strrchr(s->display_string, '.'); - if (dot) + if (dot && strlen (dot) < strlen (colon)) sprintf(dot, ".%i", screen_num); } - PRINT_DEBUG (("%s\n", s->display_string)); + PRINT_DEBUG (("display string: %s\n", s->display_string)); s->screen_num = screen_num; s->xine_screen_num = xine_screen_num; -- cgit v1.2.3