[PATCH 7/8] xf86XvMCScreenInit: Avoid leak if dixRegisterPrivateKey fails
Alan Coopersmith
alan.coopersmith at oracle.com
Mon Jan 28 17:08:41 PST 2013
Found by parfait 1.1 memory analyser:
Memory leak of pointer 'pAdapt' allocated with malloc((88 * num_adaptors))
at line 162 of hw/xfree86/common/xf86xvmc.c in function 'xf86XvMCScreenInit'.
'pAdapt' allocated at line 158 with malloc((88 * num_adaptors)).
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
hw/xfree86/common/xf86xvmc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/xfree86/common/xf86xvmc.c b/hw/xfree86/common/xf86xvmc.c
index 78a32bf..3169c05 100644
--- a/hw/xfree86/common/xf86xvmc.c
+++ b/hw/xfree86/common/xf86xvmc.c
@@ -158,8 +158,10 @@ xf86XvMCScreenInit(ScreenPtr pScreen,
if (!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
return FALSE;
- if (!dixRegisterPrivateKey(&XF86XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
+ if (!dixRegisterPrivateKey(&XF86XvMCScreenKeyRec, PRIVATE_SCREEN, 0)) {
+ free(pAdapt);
return FALSE;
+ }
if (!(pScreenPriv = malloc(sizeof(xf86XvMCScreenRec)))) {
free(pAdapt);
--
1.7.9.2
More information about the xorg-devel
mailing list