dovecot: Crashfix when calling driver_pgsql_escape_string() and ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Nov 12 18:59:22 EET 2007


details:   http://hg.dovecot.org/dovecot/rev/ee9bc72e0ed2
changeset: 6789:ee9bc72e0ed2
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Nov 12 18:59:18 2007 +0200
description:
Crashfix when calling driver_pgsql_escape_string() and we're not connected.

diffstat:

1 file changed, 2 insertions(+), 1 deletion(-)
src/lib-sql/driver-pgsql.c |    3 ++-

diffs (20 lines):

diff -r 993760061348 -r ee9bc72e0ed2 src/lib-sql/driver-pgsql.c
--- a/src/lib-sql/driver-pgsql.c	Sun Nov 11 23:29:41 2007 +0200
+++ b/src/lib-sql/driver-pgsql.c	Mon Nov 12 18:59:18 2007 +0200
@@ -497,14 +497,15 @@ driver_pgsql_escape_string(struct sql_db
 	size_t len = strlen(string);
 	char *to;
 
-	to = t_buffer_get(len * 2 + 1);
 #ifdef HAVE_PQESCAPE_STRING_CONN
 	if (!db->connected) {
 		/* try connecting again */
 		(void)driver_pgsql_connect(&db->api);
 	}
+	to = t_buffer_get(len * 2 + 1);
 	len = PQescapeStringConn(db->pg, to, string, len, NULL);
 #else
+	to = t_buffer_get(len * 2 + 1);
 	len = PQescapeString(to, string, len);
 #endif
 	t_buffer_alloc(len + 1);


More information about the dovecot-cvs mailing list