aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <sreeharsha@totakura.in>2015-03-05 16:08:55 +0100
committerSree Harsha Totakura <sreeharsha@totakura.in>2015-03-05 16:08:55 +0100
commitf7b5cf02ae0f25af55032e32bc09f21b81b551e7 (patch)
tree9ec4611c0c5c4c50c94bb2ab148bb57241aae0be
parent73d3144a13abe53169eeb01e00cf496a23673466 (diff)
downloadexchange-f7b5cf02ae0f25af55032e32bc09f21b81b551e7.tar.gz
exchange-f7b5cf02ae0f25af55032e32bc09f21b81b551e7.zip
Fix ResultSpec processing
-rw-r--r--src/pq/db_pq.c30
1 files 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,
94 { 94 {
95 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 95 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
96 "field '%s' does not exist in result\n", 96 "field '%s' does not exist in result\n",
97 rs->fname); 97 rs[i].fname);
98 return GNUNET_SYSERR; 98 return GNUNET_SYSERR;
99 } 99 }
100 100
@@ -111,26 +111,28 @@ TALER_DB_extract_result (PGresult *result,
111 (rs[i].dst_size != len) ) 111 (rs[i].dst_size != len) )
112 { 112 {
113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
114 "field '%s' has wrong size (got %d, expected %d)\n", 114 "field '%s' has wrong size (got %u, expected %u)\n",
115 rs[i].fname, 115 rs[i].fname,
116 (int) len, 116 (unsigned int) len,
117 (int) rs->dst_size); 117 (unsigned int) rs[i].dst_size);
118 for (j=0;j<i;j++) 118 for (j=0; j<i; j++)
119 if (0 == rs[i].dst_size) 119 if (0 == rs[j].dst_size)
120 { 120 {
121 GNUNET_free (rs[i].dst); 121 GNUNET_free (rs[j].dst);
122 rs[i].dst = NULL; 122 rs[j].dst = NULL;
123 *rs[i].result_size = 0; 123 *rs[j].result_size = 0;
124 } 124 }
125 return GNUNET_SYSERR; 125 return GNUNET_SYSERR;
126 } 126 }
127 res = PQgetvalue (result, row, fnum); 127 res = PQgetvalue (result, row, fnum);
128 GNUNET_assert (NULL != res); 128 GNUNET_assert (NULL != res);
129 if (0 == rs->dst_size) 129 if (0 == rs[i].dst_size)
130 *(void**) rs->dst = GNUNET_malloc (*rs->result_size = len); 130 {
131 memcpy (rs->dst, 131 *rs[i].result_size = len;
132 res, 132 *((void **) rs[i].dst) = GNUNET_malloc (len);
133 len); 133 rs[i].dst = *((void **) rs[i].dst);
134 }
135 memcpy (rs[i].dst, res, len);
134 } 136 }
135 if (GNUNET_YES == had_null) 137 if (GNUNET_YES == had_null)
136 return GNUNET_NO; 138 return GNUNET_NO;