[PATCH 4/5] xf86SbusCmapLoadPalette: Delay malloc until needed, avoiding leak on error
Alan Coopersmith
alan.coopersmith at oracle.com
Sun Feb 10 12:39:35 PST 2013
Reported with other leaks found by cppcheck in bugzilla #50281
https://bugs.freedesktop.org/show_bug.cgi?id=50281
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
hw/xfree86/common/xf86sbusBus.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c
index b6a6b94..38adeeb 100644
--- a/hw/xfree86/common/xf86sbusBus.c
+++ b/hw/xfree86/common/xf86sbusBus.c
@@ -641,14 +641,14 @@ xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
int i, index;
sbusCmapPtr cmap;
struct fbcmap fbcmap;
- unsigned char *data = malloc(numColors * 3);
+ unsigned char *data;
cmap = SBUSCMAPPTR(pScrn->pScreen);
if (!cmap)
return;
fbcmap.count = 0;
fbcmap.index = indices[0];
- fbcmap.red = data;
+ fbcmap.red = data = malloc(numColors * 3);
fbcmap.green = data + numColors;
fbcmap.blue = fbcmap.green + numColors;
for (i = 0; i < numColors; i++) {
--
1.7.9.2
More information about the xorg-devel
mailing list