Skip to content

Commit

Permalink
[BZ #346]
Browse files Browse the repository at this point in the history
Update.
	* libio/vasprintf.c (_IO_vasprintf): Fix condition to decide
	whether to realloc or not.
	Reported by Pavel Kankovsky <peak@argo.troja.mff.cuni.cz> [BZ #346].
  • Loading branch information
Ulrich Drepper committed Sep 26, 2004
1 parent ac5e137 commit 5cec955
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
2004-09-25 Ulrich Drepper <drepper@redhat.com>

* libio/vasprintf.c (_IO_vasprintf): Fix condition to decide
whether to realloc or not.
Reported by Pavel Kankovsky <peak@argo.troja.mff.cuni.cz> [BZ #346].

* intl/dcigettext.c (DCIGETTEXT): Protect tfind/tsearch calls.
* intl/dcigettext.c (_nl_find_msg): Call _nl_load_domain also if
decided < 0.
Expand Down
8 changes: 4 additions & 4 deletions libio/vasprintf.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1995,1997,1999,2000,2001,2002 Free Software Foundation, Inc.
/* Copyright (C) 1995,1997,1999-2002,2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -64,11 +64,11 @@ _IO_vasprintf (result_ptr, format, args)
free (sf._sbf._f._IO_buf_base);
return ret;
}
/* Only use realloc if the size we need is of the same order of
magnitude then the memory we allocated. */
/* Only use realloc if the size we need is of the same (binary)
order of magnitude then the memory we allocated. */
needed = sf._sbf._f._IO_write_ptr - sf._sbf._f._IO_write_base + 1;
allocated = sf._sbf._f._IO_write_end - sf._sbf._f._IO_write_base;
if ((allocated << 1) <= needed)
if ((allocated >> 1) <= needed)
*result_ptr = (char *) realloc (sf._sbf._f._IO_buf_base, needed);
else
{
Expand Down

0 comments on commit 5cec955

Please sign in to comment.