deltas: Handle cleanup of fd array properly

If there's an early error, part_temp_fds will be NULL and dereferencing
the len member will segfault.

Closes: #454

Closes: #448
Approved by: cgwalters
This commit is contained in:
Dan Nicholson 2016-08-09 11:45:25 -07:00 committed by Atomic Bot
parent 07ec35ef03
commit 1e5ff71c49
1 changed files with 8 additions and 7 deletions

View File

@ -1584,13 +1584,14 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
ret = TRUE; ret = TRUE;
out: out:
for (i = 0; i < part_temp_fds->len; i++) if (part_temp_fds)
{ for (i = 0; i < part_temp_fds->len; i++)
int fd = g_array_index (part_temp_fds, int, i); {
if (fd == -1) int fd = g_array_index (part_temp_fds, int, i);
continue; if (fd == -1)
(void) close (fd); continue;
} (void) close (fd);
}
g_clear_pointer (&builder.parts, g_ptr_array_unref); g_clear_pointer (&builder.parts, g_ptr_array_unref);
g_clear_pointer (&builder.fallback_objects, g_ptr_array_unref); g_clear_pointer (&builder.fallback_objects, g_ptr_array_unref);
return ret; return ret;