From: Timo Sirainen Date: Thu, 9 Apr 2009 23:31:22 +0000 (-0400) Subject: dict-sql: Don't crash if iteration sees a NULL value in path. X-Git-Tag: 2.0.alpha1~996 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dbd0e4bdade17c60769642c13f1632002135971e;p=thirdparty%2Fdovecot%2Fcore.git dict-sql: Don't crash if iteration sees a NULL value in path. --HG-- branch : HEAD --- diff --git a/src/lib-dict/dict-sql.c b/src/lib-dict/dict-sql.c index 1260e4b441..8475047ca8 100644 --- a/src/lib-dict/dict-sql.c +++ b/src/lib-dict/dict-sql.c @@ -395,7 +395,7 @@ static int sql_dict_iterate(struct dict_iterate_context *_ctx, { struct sql_dict_iterate_context *ctx = (struct sql_dict_iterate_context *)_ctx; - const char *p; + const char *p, *value; unsigned int i, count; int ret; @@ -426,8 +426,9 @@ static int sql_dict_iterate(struct dict_iterate_context *_ctx, str_append_c(ctx->key, *p); else { i_assert(i < count); - str_append(ctx->key, - sql_result_get_field_value(ctx->result, i)); + value = sql_result_get_field_value(ctx->result, i); + if (value != NULL) + str_append(ctx->key, value); i++; } }