[MPlayer-dev-eng] [PATCH] fix for Xv when shared memory allocation failed

joerg at britannica.bec.de joerg at britannica.bec.de
Tue Nov 15 18:23:11 CET 2005


Hi,
attached fixes a problem with the initialisation of Xv. When the shmget
failed, libX11 would abort due to invalid parameters. This can happen
e.g. on NetBSD with the GENERIC kernel and PostgreSQL running in the
background. Ideally the shmat would be checked too, but that would make
the patch more messy.

Joerg
-------------- next part --------------
--- vo_xv.c.orig	2005-11-15 18:12:35.000000000 +0100
+++ vo_xv.c
@@ -483,14 +483,20 @@ static void allocate_xvimage(int foo)
 
         Shminfo[foo].shmid =
             shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777);
-        Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0);
-        Shminfo[foo].readOnly = False;
-
-        xvimage[foo]->data = Shminfo[foo].shmaddr;
-        XShmAttach(mDisplay, &Shminfo[foo]);
-        XSync(mDisplay, False);
-        shmctl(Shminfo[foo].shmid, IPC_RMID, 0);
-    } else
+	if (Shminfo[foo].shmid == -1)
+	    Shmem_Flag = 0;
+	else
+	{
+    	    Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0);
+    	    Shminfo[foo].readOnly = False;
+
+    	    xvimage[foo]->data = Shminfo[foo].shmaddr;
+	    XShmAttach(mDisplay, &Shminfo[foo]);
+    	    XSync(mDisplay, False);
+    	    shmctl(Shminfo[foo].shmid, IPC_RMID, 0);
+	}
+    }
+    if (!Shmem_Flag)
 #endif
     {
         xvimage[foo] =


More information about the MPlayer-dev-eng mailing list