Fixed bug 1805 - Memory Leak issue in src/video/x11/edid-parse.c file
authorSam Lantinga <slouken@libsdl.org>
Wed, 17 Apr 2013 01:38:59 -0700
changeset 7072 1d9b4b7a8ce3
parent 7071 82f17e656125
child 7073 873715d91f83
Fixed bug 1805 - Memory Leak issue in src/video/x11/edid-parse.c file Nitz In Function, MonitorInfo * decode_edid (const uchar *edid) In this function "info" is going out of scope and leaks the storage it points to, if the first if condition get true: if (!decode_header (edid)) return NULL; So while returning from this if statement there should be free for "info" pointer.
src/video/x11/edid-parse.c
--- a/src/video/x11/edid-parse.c	Wed Apr 17 01:35:10 2013 -0700
+++ b/src/video/x11/edid-parse.c	Wed Apr 17 01:38:59 2013 -0700
@@ -524,29 +524,17 @@
 
     decode_check_sum (edid, info);
     
-    if (!decode_header (edid))
-	return NULL;
-
-    if (!decode_vendor_and_product_identification (edid, info))
-	return NULL;
-
-    if (!decode_edid_version (edid, info))
-	return NULL;
-
-    if (!decode_display_parameters (edid, info))
+    if (!decode_header (edid) ||
+        !decode_vendor_and_product_identification (edid, info) ||
+        !decode_edid_version (edid, info) ||
+        !decode_display_parameters (edid, info) ||
+        !decode_color_characteristics (edid, info) ||
+        !decode_established_timings (edid, info) ||
+        !decode_standard_timings (edid, info) ||
+        !decode_descriptors (edid, info)) {
+        free(info);
 	return NULL;
-
-    if (!decode_color_characteristics (edid, info))
-	return NULL;
-
-    if (!decode_established_timings (edid, info))
-	return NULL;
-
-    if (!decode_standard_timings (edid, info))
-	return NULL;
-    
-    if (!decode_descriptors (edid, info))
-	return NULL;
+    }
     
     return info;
 }