diff options
Diffstat (limited to 'hw/xquartz/quartz.c')
-rw-r--r-- | hw/xquartz/quartz.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c index 11e5a74d7..7de7138c4 100644 --- a/hw/xquartz/quartz.c +++ b/hw/xquartz/quartz.c @@ -464,11 +464,15 @@ void QuartzSpaceChanged(uint32_t space_id) { void QuartzCopyDisplayIDs(ScreenPtr pScreen, int displayCount, CGDirectDisplayID *displayIDs) { QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - int size = displayCount * sizeof(CGDirectDisplayID); free(pQuartzScreen->displayIDs); - pQuartzScreen->displayIDs = malloc(size); - memcpy(pQuartzScreen->displayIDs, displayIDs, size); + if(displayCount) { + size_t size = displayCount * sizeof(CGDirectDisplayID); + pQuartzScreen->displayIDs = malloc(size); + memcpy(pQuartzScreen->displayIDs, displayIDs, size); + } else { + pQuartzScreen->displayIDs = NULL; + } pQuartzScreen->displayCount = displayCount; } |