axmap: Avoid memory leak if axmap_new() failed
authorErwan Velu <erwan.velu@enovance.com>
Thu, 19 Feb 2015 12:09:09 +0000 (13:09 +0100)
committerErwan Velu <erwan.velu@enovance.com>
Thu, 19 Feb 2015 12:12:12 +0000 (13:12 +0100)
The axmap_new() function implements an exit path using the label "err"
to free the alloced memory.

That cleanup code was cleaning all the sub malloc structures but not the
main structure (axmap) itself resulting in a memory leak of
sizeof(struct axmap) bytes.

This simple patch just free axmap at the end of the cleanup code.

lib/axmap.c

index 164300f254014b10ed6e04e3e06b7263aa917aac..195d333c58d28c7d54e7c45b552a70781e3e08ca 100644 (file)
@@ -125,6 +125,7 @@ err:
                        free(axmap->levels[i].map);
 
        free(axmap->levels);
+        free(axmap);
        return NULL;
 }