fiasco: Call free at correct place

This commit is contained in:
Pali Rohár committed 2014-09-29 00:42:52 +02:00
1 parent d88176dbef
commit 23b916bcc9
1 file changed
+9 -5
+9 -5
View File
@@ -493,8 +493,10 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
if ( image->layout ) {
layout_name = calloc(1, strlen(name) + strlen(".layout") + 1);
if ( ! layout_name )
if ( ! layout_name ) {
free(name);
ALLOC_ERROR_RETURN(-1);
}
sprintf(layout_name, "%s.layout", name);
@@ -512,8 +514,6 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
}
}
free(name);
image_seek(image, 0);
while ( 1 ) {
size = image_read(image, buf, sizeof(buf));
@@ -522,6 +522,9 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
WRITE_OR_FAIL(name, fd, buf, size);
}
free(name);
if ( ! simulate )
close(fd);
if ( image->layout ) {
@@ -534,10 +537,11 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
}
}
free(layout_name);
WRITE_OR_FAIL(layout_name, fd, image->layout, (int)strlen(image->layout));
free(layout_name);
if ( ! simulate )
close(fd);
}