dovecot-1.1: imap_quote(): Don't crash if allocating from data s...

dovecot at dovecot.org dovecot at dovecot.org
Thu Mar 6 10:27:06 EET 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/7d4f7c7095dd
changeset: 7357:7d4f7c7095dd
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Mar 06 09:42:16 2008 +0200
description:
imap_quote(): Don't crash if allocating from data stack pool.

diffstat:

1 file changed, 8 insertions(+), 6 deletions(-)
src/lib-imap/imap-quote.c |   14 ++++++++------

diffs (30 lines):

diff -r 25551453b13c -r 7d4f7c7095dd src/lib-imap/imap-quote.c
--- a/src/lib-imap/imap-quote.c	Thu Mar 06 02:08:44 2008 +0200
+++ b/src/lib-imap/imap-quote.c	Thu Mar 06 09:42:16 2008 +0200
@@ -91,18 +91,20 @@ const char *imap_quote(pool_t pool, cons
 const char *imap_quote(pool_t pool, const unsigned char *value,
 		       size_t value_len)
 {
+	string_t *str;
 	char *ret;
 
 	if (value == NULL)
 		return "NIL";
 
-	T_BEGIN {
-		   string_t *str;
+	if (!pool->datastack_pool)
+		t_push();
 
-		   str = t_str_new(value_len + MAX_INT_STRLEN + 5);
-		   imap_quote_append(str, value, value_len, TRUE);
-		   ret = p_strndup(pool, str_data(str), str_len(str));
-	} T_END;
+	str = t_str_new(value_len + MAX_INT_STRLEN + 5);
+	imap_quote_append(str, value, value_len, TRUE);
+	ret = p_strndup(pool, str_data(str), str_len(str));
 
+	if (!pool->datastack_pool)
+		t_pop();
 	return ret;
 }


More information about the dovecot-cvs mailing list