mirror of
https://github.com/X11Libre/xserver.git
synced 2026-11-23 06:43:07 +00:00
xnest: Check malloc return values in GCOps to avoid NULL dereferences
Check malloc() return values for NULL in xnestBitBlitHelper(), xnestPolyText8(), and xnestPolyText16() to prevent potential NULL pointer dereferences
This commit is contained in:
parent
e5137d9fde
commit
eda471e6f0
1 changed files with 12 additions and 2 deletions
|
|
@ -189,8 +189,14 @@ 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);
|
||||
}
|
||||
else {
|
||||
free(event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -343,6 +349,8 @@ 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 x;
|
||||
xTextElt *elt = (xTextElt*)buffer;
|
||||
elt->len = count;
|
||||
elt->delta = 0;
|
||||
|
|
@ -369,6 +377,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 x;
|
||||
xTextElt *elt = (xTextElt*)buffer;
|
||||
elt->len = count;
|
||||
elt->delta = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue