[PATCH] ddc: Fix memory leak in GetEDID_DDC1

Matt Turner mattst88 at gmail.com
Tue Jul 27 20:32:36 PDT 2010


Mark argument to DDC_checksum as const too.

Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
 hw/xfree86/ddc/ddc.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/ddc/ddc.c b/hw/xfree86/ddc/ddc.c
index 7379e95..2d9d4dc 100644
--- a/hw/xfree86/ddc/ddc.c
+++ b/hw/xfree86/ddc/ddc.c
@@ -102,7 +102,7 @@ resort(unsigned char *s_block)
 }
 
 static int
-DDC_checksum(unsigned char *block, int len)
+DDC_checksum(const unsigned char *block, int len)
 {
     int i, result = 0;
     int not_null = 0;
@@ -149,7 +149,10 @@ GetEDID_DDC1(unsigned int *s_ptr)
 	d_pos++;
     }
     free(s_ptr);
-    if (d_block && DDC_checksum(d_block,EDID1_LEN)) return NULL;
+    if (d_block && DDC_checksum(d_block,EDID1_LEN)) {
+	free(d_block);
+	return NULL;
+    }
     return (resort(d_block));
 }
 
-- 
1.7.1



More information about the xorg-devel mailing list