Skip to content

Commit

Permalink
[BZ #10100]
Browse files Browse the repository at this point in the history
2009-04-24  Ulrich Drepper  <drepper@redhat.com>
	[BZ #10100]
	* misc/hsearch_r.c (hsearch_r): Add back ensurance that hval is
	not zero.
  • Loading branch information
Ulrich Drepper committed Apr 24, 2009
1 parent f397be1 commit c2d5bd5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2009-04-24 Ulrich Drepper <drepper@redhat.com>

[BZ #10100]
* misc/hsearch_r.c (hsearch_r): Add back ensurance that hval is
not zero.

2009-04-24 Jakub Jelinek <jakub@redhat.com>

* iconvdata/sjis.c (BODY): Don't advance inptr before
Expand Down
27 changes: 12 additions & 15 deletions locale/programs/locarchive.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,12 @@ create_archive (const char *archivefname, struct locarhandle *ah)

/* To prepare for enlargements of the mmaped area reserve some
address space. */
size_t reserved;
size_t reserved = RESERVE_MMAP_SIZE;
int xflags = 0;
p = mmap64 (NULL, RESERVE_MMAP_SIZE, PROT_NONE, MAP_ANON, -1, 0);
if (p != MAP_FAILED)
{
xflags = MAP_FIXED;
reserved = RESERVE_MMAP_SIZE;
}
if (total < RESERVE_MMAP_SIZE
&& ((p = mmap64 (NULL, reserved, PROT_NONE, MAP_ANON, -1, 0))
!= MAP_FAILED))
xflags = MAP_FIXED;
else
{
p = NULL;
Expand Down Expand Up @@ -580,14 +578,13 @@ open_archive (struct locarhandle *ah, bool readonly)

/* To prepare for enlargements of the mmaped area reserve some
address space. */
size_t reserved;
size_t reserved = RESERVE_MMAP_SIZE;
int xflags = 0;
void *p = mmap64 (NULL, RESERVE_MMAP_SIZE, PROT_NONE, MAP_ANON, -1, 0);
if (p != MAP_FAILED)
{
xflags = MAP_FIXED;
reserved = RESERVE_MMAP_SIZE;
}
void *p;
if (st.st_size < RESERVE_MMAP_SIZE
&& ((p = mmap64 (NULL, RESERVE_MMAP_SIZE, PROT_NONE, MAP_ANON, -1, 0))
!= MAP_FAILED))
xflags = MAP_FIXED;
else
{
p = NULL;
Expand All @@ -612,7 +609,7 @@ close_archive (struct locarhandle *ah)
{
if (ah->fd != -1)
{
munmap (ah->addr, ah->mmaped);
munmap (ah->addr, MAX (ah->reserved, ah->mmaped));
close (ah->fd);
}
}
Expand Down
2 changes: 2 additions & 0 deletions misc/hsearch_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ hsearch_r (item, action, retval, htab)
hval <<= 4;
hval += item.key[count];
}
if (hval == 0)
++hval;

/* First hash function: simply take the modul but prevent zero. */
idx = hval % htab->size + 1;
Expand Down

0 comments on commit c2d5bd5

Please sign in to comment.