Stop leaking overlayWin in PanoramiXCompositeGetOverlayWindow error paths

Found by parfait 1.1 code analyzer:

Error: Memory leak (CWE 401)
   Memory leak of pointer 'overlayWin' allocated with malloc(72)
        at line 806 of composite/compext.c in function 'PanoramiXCompositeGetOverlayWindow'.
          pointer allocated at line 794 with malloc(72).
          <unknown> leaks when rc != 0 at line 804.
        at line 816 of composite/compext.c in function 'PanoramiXCompositeGetOverlayWindow'.
          pointer allocated at line 794 with malloc(72).
          <unknown> leaks when pOc == NULL at line 815.
        at line 825 of composite/compext.c in function 'PanoramiXCompositeGetOverlayWindow'.
          pointer allocated at line 794 with malloc(72).
          <unknown> leaks when cs->pOverlayWin == NULL at line 822
              and compCreateOverlayWindow(pScreen) == 0 at line 823.
        at line 834 of composite/compext.c in function 'PanoramiXCompositeGetOverlayWindow'.
          pointer allocated at line 794 with malloc(72).
          <unknown> leaks when rc != 0 at line 832.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Alan Coopersmith 2013-01-27 11:20:45 -08:00
parent f4a9332ad1
commit 48b9465120
1 changed files with 6 additions and 1 deletions

View File

@ -803,6 +803,7 @@ PanoramiXCompositeGetOverlayWindow(ClientPtr client)
RT_WINDOW, client, DixGetAttrAccess);
if (rc != Success) {
client->errorValue = stuff->window;
free(overlayWin);
return rc;
}
pScreen = pWin->drawable.pScreen;
@ -812,8 +813,10 @@ PanoramiXCompositeGetOverlayWindow(ClientPtr client)
* interest in the overlay window
*/
pOc = compCreateOverlayClient(pScreen, client);
if (pOc == NULL)
if (pOc == NULL) {
free(overlayWin);
return BadAlloc;
}
/*
* Make sure the overlay window exists
@ -822,6 +825,7 @@ PanoramiXCompositeGetOverlayWindow(ClientPtr client)
if (cs->pOverlayWin == NULL)
if (!compCreateOverlayWindow(pScreen)) {
FreeResource(pOc->resource, RT_NONE);
free(overlayWin);
return BadAlloc;
}
@ -831,6 +835,7 @@ PanoramiXCompositeGetOverlayWindow(ClientPtr client)
DixGetAttrAccess);
if (rc != Success) {
FreeResource(pOc->resource, RT_NONE);
free(overlayWin);
return rc;
}
}