image: Fix memory leaks

This commit is contained in:
Pali Rohár committed 2014-09-29 00:43:15 +02:00
1 parent 23b916bcc9
commit dfc021d7c4
1 file changed
+4 -3
+4 -3
View File
@@ -88,14 +88,13 @@ static void image_missing_values_from_name(struct image * image, const char * na
if ( image->devices && image->devices->device && ! image->devices->hwrevs )
image->devices->hwrevs = hwrevs_alloc_from_string(hwrevs);
else
free(hwrevs);
if ( ! image->version )
image->version = version;
else
free(version);
free(hwrevs);
free(str);
}
@@ -135,8 +134,10 @@ char * image_name_alloc_from_values(struct image * image) {
length += 1 + strlen(image->version);
name = calloc(1, length);
if ( ! name )
if ( ! name ) {
free(hwrevs);
ALLOC_ERROR_RETURN(NULL);
}
strcpy(name, type);
ptr = name + strlen(name);