diff --git a/gcc/collect2.c b/gcc/collect2.c index cf04a58ba4d..d47fe3f9195 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -2299,10 +2299,15 @@ is_lto_object_file (const char *prog_name) LTO_SEGMENT_NAME, &errmsg, &err); if (!inobj) - return false; + { + close (infd); + return false; + } errmsg = simple_object_find_sections (inobj, has_lto_section, (void *) &found, &err); + simple_object_release_read (inobj); + close (infd); if (! errmsg && found) return true;