summaryrefslogtreecommitdiff
path: root/locale/loadarchive.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-08-28 22:37:20 +0000
committerUlrich Drepper <drepper@redhat.com>2002-08-28 22:37:20 +0000
commitdd4f211573cfbed669f582673e8914a1f7038cd9 (patch)
treec5b7959be74aba89939f7352619be1149cba39d9 /locale/loadarchive.c
parent669ed638144a784bd7fdea2e922ddf5e85a6b2bc (diff)
downloadglibc-dd4f211573cfbed669f582673e8914a1f7038cd9.tar.gz
Update.
2002-08-28 Jakub Jelinek <jakub@redhat.com> * sysdeps/ia64/elf/configure.in (PI_STATIC_AND_HIDDEN): Define unconditionally. * sysdeps/alpha/elf/configure.in (libc_cv_alpha_hidden_gprel): New check. (PI_STATIC_AND_HIDDEN): Define if check succeeded. 2002-08-28 Jakub Jelinek <jakub@redhat.com> * locale/loadarchive.c (_nl_load_locale_from_archive): Add fd >= 0 check to close_and_out close. Replace return NULL statements where fd might be >= 0 with goto close_and_out. Close the file descriptor when it is no longer needed.
Diffstat (limited to 'locale/loadarchive.c')
-rw-r--r--locale/loadarchive.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index ab824a7dba..e8235c9a4d 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -211,7 +211,8 @@ _nl_load_locale_from_archive (int category, const char **namep)
{
/* stat failed, very strange. */
close_and_out:
- __close (fd);
+ if (fd >= 0)
+ __close (fd);
return NULL;
}
@@ -262,7 +263,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
/* If there is no archive or it cannot be loaded for some reason fail. */
if (__builtin_expect (headmap.ptr == NULL, 0))
- return NULL;
+ goto close_and_out;
/* We have the archive available. To find the name we first have to
determine its hash value. */
@@ -281,7 +282,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
{
if (namehashtab[idx].name_offset == 0)
/* Not found. */
- return NULL;
+ goto close_and_out;
if (namehashtab[idx].hashval == hval
&& strcmp (name, headmap.ptr + namehashtab[idx].name_offset) == 0)
@@ -295,7 +296,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
/* We found an entry. It might be a placeholder for a removed one. */
if (namehashtab[idx].locrec_offset == 0)
- return NULL;
+ goto close_and_out;
locrec = (struct locrecent *) (headmap.ptr + namehashtab[idx].locrec_offset);
@@ -309,7 +310,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
if (locrec->record[cnt].offset + locrec->record[cnt].len
> headmap.len)
/* The archive locrectab contains bogus offsets. */
- return NULL;
+ goto close_and_out;
results[cnt].addr = headmap.ptr + locrec->record[cnt].offset;
results[cnt].len = locrec->record[cnt].len;
}
@@ -376,7 +377,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
to = ranges[upper].from + ranges[upper].len;
if (to > (size_t) archive_stat.st_size)
/* The archive locrectab contains bogus offsets. */
- return NULL;
+ goto close_and_out;
to = (to + ps - 1) & ~(ps - 1);
/* If a range is already mmaped in, stop. */
@@ -404,21 +405,21 @@ _nl_load_locale_from_archive (int category, const char **namep)
|| st.st_mtime != archive_stat.st_mtime
|| st.st_dev != archive_stat.st_dev
|| st.st_ino != archive_stat.st_ino)
- return NULL;
+ goto close_and_out;
}
/* Map the range from the archive. */
addr = __mmap64 (NULL, to - from, PROT_READ, MAP_FILE|MAP_COPY,
fd, from);
if (addr == MAP_FAILED)
- return NULL;
+ goto close_and_out;
/* Allocate a record for this mapping. */
newp = (struct archmapped *) malloc (sizeof (struct archmapped));
if (newp == NULL)
{
(void) __munmap (addr, to - from);
- return NULL;
+ goto close_and_out;
}
/* And queue it. */
@@ -443,6 +444,11 @@ _nl_load_locale_from_archive (int category, const char **namep)
}
}
+ /* We don't need the file descriptor any longer. */
+ if (fd >= 0)
+ __close (fd);
+ fd = -1;
+
/* We succeeded in mapping all the necessary regions of the archive.
Now we need the expected data structures to point into the data. */