summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2010-07-13 08:25:27 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2010-07-13 08:27:36 -0700
commit648d189548530fa23d97d1e8737f89d297f1c443 (patch)
tree8c280de613c62708ce254d71ce38b5cfb54d4a92 /hw
parent3209b094a3b1466b579e8020e12a4f3fa78a5f3f (diff)
XQuartz: Avoid a crash when mistakenly free()ing in QuartzSetCursor on some configs
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/xquartz/xpr/xprCursor.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index 67fcbe76e..a106e7241 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -67,6 +67,7 @@ static Bool
load_cursor(CursorPtr src, int screen)
{
uint32_t *data;
+ Bool free_data = FALSE;
uint32_t rowbytes;
int width, height;
int hot_x, hot_y;
@@ -95,6 +96,7 @@ load_cursor(CursorPtr src, int screen)
unsigned i;
rowbytes = src->bits->width * sizeof (CARD32);
data = malloc(rowbytes * src->bits->height);
+ free_data = TRUE;
if(!data) {
FatalError("Failed to allocate memory in %s\n", __func__);
}
@@ -121,6 +123,7 @@ 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 = malloc(rowbytes * src->bits->height);
+ free_data = TRUE;
if(!data) {
FatalError("Failed to allocate memory in %s\n", __func__);
}
@@ -173,7 +176,8 @@ load_cursor(CursorPtr src, int screen)
}
err = xp_set_cursor(width, height, hot_x, hot_y, data, rowbytes);
- free(data);
+ if(free_data)
+ free(data);
return err == Success;
}