File u_01-Xephyr-Don-t-crash-when-no-command-line-argument-is-specified.patch of Package xorg-x11-server.1462

From: Egbert Eich <eich@suse.de>
Date: Mon Mar 30 17:36:47 2015 +0200
Subject: [PATCH 1/2]Xephyr: Don't crash when no command line argument is specified
Patch-mainline: to be upstreamed

References: bnc#925022
Signed-off-by: Egbert Eich <eich@suse.de>

The DDX specific command line parsing function only gets called
if command line arguments are present. Therefore this function
is not suitable to initialize mandatory global variables.
Replace main() instead.

Signed-off-by: Egbert Eich <eich@suse.de>
---
 configure.ac                |  4 +++-
 hw/kdrive/ephyr/ephyrinit.c | 14 +++++++++-----
 hw/kdrive/fake/Makefile.am  |  1 +
 hw/kdrive/fbdev/Makefile.am |  1 +
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index ce7c1bb..5951737 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2358,7 +2358,8 @@ if test "$KDRIVE" = yes; then
 	    ;;
     esac
     KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.la'
-    KDRIVE_LOCAL_LIBS="$MAIN_LIB $DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB"
+    KDRIVE_MAIN_LIB="$MAIN_LIB"
+    KDRIVE_LOCAL_LIBS="$DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB"
     KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $FB_LIB $MI_LIB $KDRIVE_PURE_LIBS"
     KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB"
     KDRIVE_LIBS="$KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS $GLX_SYS_LIBS $DLOPEN_LIBS $TSLIB_LIBS"
@@ -2370,6 +2371,7 @@ AC_SUBST([KDRIVE_INCS])
 AC_SUBST([KDRIVE_PURE_INCS])
 AC_SUBST([KDRIVE_CFLAGS])
 AC_SUBST([KDRIVE_PURE_LIBS])
+AC_SUBST([KDRIVE_MAIN_LIB])
 AC_SUBST([KDRIVE_LOCAL_LIBS])
 AC_SUBST([KDRIVE_LIBS])
 AM_CONDITIONAL(KDRIVELINUX, [test "x$KDRIVELINUX" = xyes])
diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index cf8bc90..dac0656 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -48,6 +48,15 @@ extern KdKeyboardDriver LinuxEvdevKeyboardDriver;
 
 void processScreenArg(const char *screen_size, char *parent_id);
 
+int dix_main(int argc, char *argv[], char *envp[]);
+
+int
+main(int argc, char *argv[], char *envp[])
+{
+    hostx_use_resname(basename(argv[0]), 0);
+    return dix_main(argc, argv, envp);
+}
+
 void
 InitCard(char *name)
 {
@@ -70,7 +79,6 @@ void ephyrExtensionInit(void)
  LoadExtension(&ephyrExtensions[i], TRUE);
 }
 
-
 void
 InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
 {
@@ -189,10 +197,6 @@ ddxProcessArgument(int argc, char **argv, int i)
 
     EPHYR_DBG("mark argv[%d]='%s'", i, argv[i]);
 
-    if (i == 1) {
-        hostx_use_resname(basename(argv[0]), 0);
-    }
-
     if (!strcmp(argv[i], "-parent")) {
         if (i + 1 < argc) {
             int j;
diff --git a/hw/kdrive/fake/Makefile.am b/hw/kdrive/fake/Makefile.am
index 14c99c3..d28bd27 100644
--- a/hw/kdrive/fake/Makefile.am
+++ b/hw/kdrive/fake/Makefile.am
@@ -18,6 +18,7 @@ Xfake_SOURCES = \
 
 Xfake_LDADD = 						\
 	libfake.la					\
+	@KDRIVE_MAIN_LIB@				\
 	@KDRIVE_LIBS@
 
 Xfake_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
diff --git a/hw/kdrive/fbdev/Makefile.am b/hw/kdrive/fbdev/Makefile.am
index 7e8ba02..d550c13 100644
--- a/hw/kdrive/fbdev/Makefile.am
+++ b/hw/kdrive/fbdev/Makefile.am
@@ -16,6 +16,7 @@ Xfbdev_SOURCES = \
 
 Xfbdev_LDADD = 						\
 	libfbdev.la					\
+	@KDRIVE_MAIN_LIB@				\
 	@KDRIVE_LIBS@
 
 Xfbdev_DEPENDENCIES =	\
openSUSE Build Service is sponsored by