repart: Make sure we clean up temporary files created in context_minimize()
This commit is contained in:
@@ -211,6 +211,7 @@ struct Partition {
|
||||
FreeArea *allocated_to_area;
|
||||
|
||||
char *copy_blocks_path;
|
||||
bool copy_blocks_path_is_our_file;
|
||||
bool copy_blocks_auto;
|
||||
const char *copy_blocks_root;
|
||||
int copy_blocks_fd;
|
||||
@@ -340,7 +341,10 @@ static Partition* partition_free(Partition *p) {
|
||||
if (p->new_partition)
|
||||
fdisk_unref_partition(p->new_partition);
|
||||
|
||||
free(p->copy_blocks_path);
|
||||
if (p->copy_blocks_path_is_our_file)
|
||||
unlink_and_free(p->copy_blocks_path);
|
||||
else
|
||||
free(p->copy_blocks_path);
|
||||
safe_close(p->copy_blocks_fd);
|
||||
|
||||
free(p->format);
|
||||
@@ -5321,6 +5325,7 @@ static int context_minimize(Context *context) {
|
||||
* loopback file for us. */
|
||||
if (fstype_is_ro(p->format)) {
|
||||
p->copy_blocks_path = TAKE_PTR(temp);
|
||||
p->copy_blocks_path_is_our_file = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5378,6 +5383,7 @@ static int context_minimize(Context *context) {
|
||||
}
|
||||
|
||||
p->copy_blocks_path = TAKE_PTR(temp);
|
||||
p->copy_blocks_path_is_our_file = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user