From 628e36226ca8f38df9e5d8c84550f867b1485565 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 6 May 2025 17:41:29 +0200 Subject: [PATCH] xnest --- hw/xnest/GC.c | 5 +++-- hw/xnest/GCOps.c | 11 +++++++++-- hw/xnest/Screen.c | 1 + hw/xnest/Window.c | 6 ++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c index 15a6d03c6..00b0af493 100644 --- a/hw/xnest/GC.c +++ b/hw/xnest/GC.c @@ -148,9 +148,10 @@ xnestChangeGC(GCPtr pGC, unsigned long mask) if (mask & GCTileStipYOrigin) values.tile_stipple_origin_y = pGC->patOrg.y; - if (mask & GCFont) + if (mask & GCFont) { + assert(xnestFontPriv(pGC->font)); values.font = xnestFontPriv(pGC->font)->font_id; - + } if (mask & GCSubwindowMode) values.subwindow_mode = pGC->subWindowMode; diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c index 0fbbf6eb0..23ecd966b 100644 --- a/hw/xnest/GCOps.c +++ b/hw/xnest/GCOps.c @@ -190,8 +190,10 @@ xnestBitBlitHelper(GCPtr pGC) default: { struct xnest_event_queue *q = malloc(sizeof(struct xnest_event_queue)); - q->event = event; - xorg_list_add(&q->entry, &xnestUpstreamInfo.eventQueue.entry); + if (q) { + q->event = event; + xorg_list_add(&q->entry, &xnestUpstreamInfo.eventQueue.entry); + } } } } @@ -344,6 +346,9 @@ xnestPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, // won't get more than 254 elements, since it's already processed by doPolyText() int const bufsize = sizeof(xTextElt) + count; uint8_t *buffer = malloc(bufsize); + if (!buffer) + return 0; + xTextElt *elt = (xTextElt*)buffer; elt->len = count; elt->delta = 0; @@ -370,6 +375,8 @@ xnestPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, // won't get more than 254 elements, since it's already processed by doPolyText() int const bufsize = sizeof(xTextElt) + count*2; uint8_t *buffer = malloc(bufsize); + if (!buffer) + return 0; xTextElt *elt = (xTextElt*)buffer; elt->len = count; elt->delta = 0; diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index 7bf522a55..a5fc94a6b 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -293,6 +293,7 @@ breakout: if (!found_default_visual) { ErrorF("Xnest: can't find matching visual for user specified depth %d\n", xnestDefaultDepth); + assert(visuals); defaultVisual = visuals[0].vid; rootDepth = visuals[0].nplanes; } diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c index e8d9520cb..fa4d69076 100644 --- a/hw/xnest/Window.c +++ b/hw/xnest/Window.c @@ -440,7 +440,8 @@ xnestShapeWindow(WindowPtr pWin) int const num_rects = RegionNumRects(xnestWindowPriv(pWin)->bounding_shape); BoxPtr const pBox = RegionRects(xnestWindowPriv(pWin)->bounding_shape); xcb_rectangle_t *rects = calloc(num_rects, sizeof(xcb_rectangle_t)); - + if (!rects) + return; for (int i = 0; i < num_rects; i++) { rects[i].x = pBox[i].x1; rects[i].y = pBox[i].y1; @@ -469,7 +470,8 @@ xnestShapeWindow(WindowPtr pWin) int const num_rects = RegionNumRects(xnestWindowPriv(pWin)->clip_shape); BoxPtr const pBox = RegionRects(xnestWindowPriv(pWin)->clip_shape); xcb_rectangle_t *rects = calloc(num_rects, sizeof(xcb_rectangle_t)); - + if (!rects) + return; for (int i = 0; i < num_rects; i++) { rects[i].x = pBox[i].x1; rects[i].y = pBox[i].y1;