From a5751605c87e5355be164e6c585f5797e2b4beb3 Mon Sep 17 00:00:00 2001 From: Roland Baer Date: Tue, 8 Apr 2008 10:35:28 +0300 Subject: [PATCH] Fixed two derefs before NULL check, removed a effectivly unused variable with a bad free --- src/intel_bufmgr_exa.c | 4 +++- src/intel_bufmgr_ttm.c | 8 ++++++-- src/xvmc/I810XvMC.c | 2 -- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/intel_bufmgr_exa.c b/src/intel_bufmgr_exa.c index f4a3590..615f7bb 100644 --- a/src/intel_bufmgr_exa.c +++ b/src/intel_bufmgr_exa.c @@ -103,12 +103,14 @@ dri_exa_bo_reference(dri_bo *buf) static void dri_exa_bo_unreference(dri_bo *buf) { - dri_bufmgr_exa *bufmgr_exa = (dri_bufmgr_exa *)buf->bufmgr; + dri_bufmgr_exa *bufmgr_exa; dri_bo_exa *exa_buf = (dri_bo_exa *)buf; if (!buf) return; + bufmgr_exa = (dri_bufmgr_exa *)buf->bufmgr; + if (--exa_buf->refcount == 0) i830_free_memory(bufmgr_exa->pScrn, exa_buf->memory); } diff --git a/src/intel_bufmgr_ttm.c b/src/intel_bufmgr_ttm.c index c1ad8c7..6e2dfe6 100644 --- a/src/intel_bufmgr_ttm.c +++ b/src/intel_bufmgr_ttm.c @@ -447,12 +447,14 @@ dri_ttm_bo_reference(dri_bo *buf) static void dri_ttm_bo_unreference(dri_bo *buf) { - dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr; + dri_bufmgr_ttm *bufmgr_ttm; dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf; if (!buf) return; + bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr; + if (--ttm_buf->refcount == 0) { int ret; @@ -619,12 +621,14 @@ dri_ttm_fence_reference(dri_fence *fence) static void dri_ttm_fence_unreference(dri_fence *fence) { - dri_fence_ttm *fence_ttm = (dri_fence_ttm *)fence; + dri_fence_ttm *fence_ttm; dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)fence->bufmgr; if (!fence) return; + fence_ttm = (dri_fence_ttm *)fence; + DBG("fence_unreference: %p (%s)\n", &fence_ttm->fence, fence_ttm->name); if (--fence_ttm->refcount == 0) { diff --git a/src/xvmc/I810XvMC.c b/src/xvmc/I810XvMC.c index 03be251..ce5395a 100644 --- a/src/xvmc/I810XvMC.c +++ b/src/xvmc/I810XvMC.c @@ -130,7 +130,6 @@ Status XvMCCreateContext(Display *display, XvPortID port, int surface_type_id, int width, int height, int flags, XvMCContext *context) { i810XvMCContext *pI810XvMC; - char busIdString[10]; int priv_count; uint *priv_data; uint magic; @@ -217,7 +216,6 @@ Status XvMCCreateContext(Display *display, XvPortID port, /* Open DRI Device */ if((pI810XvMC->fd = drmOpen("i810",NULL)) < 0) { printf("DRM Device for i810 could not be opened.\n"); - free(busIdString); free(pI810XvMC); return BadAccess; } /* !pI810XvMC->fd */ -- 1.5.4.3