]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap_quote(): Don't crash if allocating from data stack pool.
authorTimo Sirainen <tss@iki.fi>
Thu, 6 Mar 2008 07:42:16 +0000 (09:42 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 6 Mar 2008 07:42:16 +0000 (09:42 +0200)
--HG--
branch : HEAD

src/lib-imap/imap-quote.c

index a5a7aea8536fe144cba8b6099fa4e7539a01b485..8499bc9efda5217c409ee1c087c376a1361d467f 100644 (file)
@@ -91,18 +91,20 @@ void imap_quote_append(string_t *str, const unsigned char *value,
 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;
 }