From f7b5cf02ae0f25af55032e32bc09f21b81b551e7 Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Thu, 5 Mar 2015 16:08:55 +0100 Subject: [PATCH] Fix ResultSpec processing --- src/pq/db_pq.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/pq/db_pq.c b/src/pq/db_pq.c index f63fe765e..bfa929c4e 100644 --- a/src/pq/db_pq.c +++ b/src/pq/db_pq.c @@ -94,7 +94,7 @@ TALER_DB_extract_result (PGresult *result, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "field '%s' does not exist in result\n", - rs->fname); + rs[i].fname); return GNUNET_SYSERR; } @@ -111,26 +111,28 @@ TALER_DB_extract_result (PGresult *result, (rs[i].dst_size != len) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "field '%s' has wrong size (got %d, expected %d)\n", + "field '%s' has wrong size (got %u, expected %u)\n", rs[i].fname, - (int) len, - (int) rs->dst_size); - for (j=0;jdst_size) - *(void**) rs->dst = GNUNET_malloc (*rs->result_size = len); - memcpy (rs->dst, - res, - len); + if (0 == rs[i].dst_size) + { + *rs[i].result_size = len; + *((void **) rs[i].dst) = GNUNET_malloc (len); + rs[i].dst = *((void **) rs[i].dst); + } + memcpy (rs[i].dst, res, len); } if (GNUNET_YES == had_null) return GNUNET_NO;