xserver: Branch 'master' - 2 commits

Keith Packard keithp at kemper.freedesktop.org
Wed Dec 2 08:42:42 PST 2009


 hw/xfree86/common/xf86xv.c     |    4 ++--
 hw/xquartz/mach-startup/stub.c |   12 ++++++++----
 hw/xquartz/xpr/x-hook.c        |   12 ++++++++++--
 hw/xquartz/xpr/xprCursor.c     |   13 ++++++++++---
 4 files changed, 30 insertions(+), 11 deletions(-)

New commits:
commit 0e084d8c71e697a5cf5d5d7c749455ae14bd6eb7
Author: Luc Verhaegen <libv at skynet.be>
Date:   Wed Nov 11 15:59:27 2009 +0100

    Xv: Fix AdjustFrame when driver implements ReputImage.
    
    Should probably also be applied to stabler xserver branches too.
    
    Luc Verhaegen.
    
    From a22bc20721bad506d8fa9772b1258568cbffe7d2 Mon Sep 17 00:00:00 2001
    From: Luc Verhaegen <libv at skynet.be>
    Date: Wed, 11 Nov 2009 15:52:39 +0100
    Subject: [PATCH] Xv: Fix AdjustFrame when driver implements ReputImage.
    
    Finally fixes fd.o #4653, filed more than 4 years ago.
    
    Patch can be happily applied to all modular Xorg versions.
    
    Signed-off-by: Luc Verhaegen <libv at skynet.be>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index abbe033..8221659 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -1297,7 +1297,7 @@ xf86XVAdjustFrame(int index, int x, int y, int flags)
       for(i = pa->nPorts; i > 0; i--, pPort++) {
 	pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
 
-	if(!pPriv->type && (pPriv->isOn == XV_ON)) { /* overlaid still/image */
+	if(!pPriv->type && (pPriv->isOn != XV_OFF)) { /* overlaid still/image */
 
 	  if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
 	     REGION_DESTROY(pScreen, pPriv->pCompositeClip);
@@ -1311,7 +1311,7 @@ xf86XVAdjustFrame(int index, int x, int y, int flags)
 	      (pWin->visibility == VisibilityPartiallyObscured)))
 	  {
 	      xf86XVReputImage(pPriv);
-	  } else {
+	  } else if (pPriv->isOn == XV_ON) {
 	     (*pPriv->AdaptorRec->StopVideo)(
 				 pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
 	     xf86XVRemovePortFromWindow(pWin, pPriv);
commit f4fc3406720410e37a2bce1b782cba0f0b734e42
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Nov 30 11:03:59 2009 -0800

    XQuartz: Drop calls to alloca
    
    This makes us more consistent with the rest of the codebase, using xalloc/xfree
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at freedesktop.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index af1c59e..c8686e7 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -306,12 +306,12 @@ int main(int argc, char **argv, char **envp) {
     /* We have fixed-size string lengths due to limitations in IPC,
      * so we need to copy our argv and envp.
      */
-    newargv = (string_array_t)alloca(argc * sizeof(string_t));
-    newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
-    
+    newargv = (string_array_t)malloc(argc * sizeof(string_t));
+    newenvp = (string_array_t)malloc(envpc * sizeof(string_t));
+
     if(!newargv || !newenvp) {
         fprintf(stderr, "Xquartz: Memory allocation failure\n");
-        exit(EXIT_FAILURE);
+        return EXIT_FAILURE;
     }
     
     for(i=0; i < argc; i++) {
@@ -322,6 +322,10 @@ int main(int argc, char **argv, char **envp) {
     }
 
     kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
+
+    free(newargv);
+    free(newenvp);
+
     if (kr != KERN_SUCCESS) {
         fprintf(stderr, "Xquartz: start_x11_server: %s\n", mach_error_string(kr));
         return EXIT_FAILURE;
diff --git a/hw/xquartz/xpr/x-hook.c b/hw/xquartz/xpr/x-hook.c
index bb873bb..03e7f85 100644
--- a/hw/xquartz/xpr/x-hook.c
+++ b/hw/xquartz/xpr/x-hook.c
@@ -34,6 +34,7 @@
 #include "x-hook.h"
 #include <stdlib.h>
 #include <assert.h>
+#include "os.h"
 
 #define CELL_NEW(f,d) X_PFX (list_prepend) ((x_list *) (f), (d))
 #define CELL_FREE(c)  X_PFX (list_free_1) (c)
@@ -79,9 +80,13 @@ X_PFX (hook_run) (x_list *lst, void *arg)
     int length, i;
 
     length = X_PFX (list_length) (lst);
-    fun = alloca (sizeof (x_hook_function *) * length);
-    data = alloca (sizeof (void *) * length);
+    fun = xalloc (sizeof (x_hook_function *) * length);
+    data = xalloc (sizeof (void *) * length);
 
+    if(!fun || !data) {
+        FatalError("Failed to allocate memory in %s\n", __func__);
+    }
+    
     for (i = 0, node = lst; node != NULL; node = node->next, i++)
     {
 	cell = node->data;
@@ -93,6 +98,9 @@ X_PFX (hook_run) (x_list *lst, void *arg)
     {
 	(*fun[i]) (arg, data[i]);
     }
+    
+    xfree(fun);
+    xfree(data);
 }
 
 X_EXTERN void
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index b577fc0..fbaf825 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -95,7 +95,10 @@ load_cursor(CursorPtr src, int screen)
         const uint32_t *be_data=(uint32_t *) src->bits->argb;
         unsigned i;
         rowbytes = src->bits->width * sizeof (CARD32);
-        data=alloca (rowbytes * src->bits->height);
+        data = xalloc(rowbytes * src->bits->height);
+        if(!data) {
+            FatalError("Failed to allocate memory in %s\n", __func__);
+        }
         for(i=0;i<(src->bits->width*src->bits->height);i++)
             data[i]=ntohl(be_data[i]);
 #endif
@@ -118,8 +121,11 @@ load_cursor(CursorPtr src, int screen)
 
         /* round up to 8 pixel boundary so we can convert whole bytes */
         rowbytes = ((src->bits->width * 4) + 31) & ~31;
-        data = alloca(rowbytes * src->bits->height);
-
+        data = xalloc(rowbytes * src->bits->height);
+        if(!data) {
+            FatalError("Failed to allocate memory in %s\n", __func__);
+        }
+        
         if (!src->bits->emptyMask)
         {
             ycount = src->bits->height;
@@ -168,6 +174,7 @@ load_cursor(CursorPtr src, int screen)
     }
 
     err = xp_set_cursor(width, height, hot_x, hot_y, data, rowbytes);
+    xfree(data);
     return err == Success;
 }
 


More information about the xorg-commit mailing list