dovecot-2.2: str_*printfa(): Avoid growing underlying buffer if ...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Aug 29 16:19:12 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/fff00bb85ae4
changeset: 14966:fff00bb85ae4
user: Timo Sirainen <tss at iki.fi>
date: Wed Aug 29 16:12:08 2012 +0300
description:
str_*printfa(): Avoid growing underlying buffer if possible.
diffstat:
src/lib/str.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diffs (15 lines):
diff -r 9ae214349fac -r fff00bb85ae4 src/lib/str.c
--- a/src/lib/str.c Wed Aug 29 08:56:40 2012 +0300
+++ b/src/lib/str.c Wed Aug 29 16:12:08 2012 +0300
@@ -145,6 +145,11 @@
init_size += SNPRINTF_INITIAL_EXTRA_SIZE;
/* @UNSAFE */
+ if (init_size > buffer_get_size(str)) {
+ /* avoid growing buffer larger if possible. this is also
+ required if buffer isn't dynamically growing. */
+ init_size = buffer_get_size(str);
+ }
tmp = buffer_get_space_unsafe(str, pos, init_size);
ret = vsnprintf(tmp, init_size, fmt, args);
i_assert(ret >= 0);
More information about the dovecot-cvs
mailing list