summaryrefslogtreecommitdiff
path: root/src/my
diff options
context:
space:
mode:
authorChristophe Genevey Metat <genevey.christophe@gmail.com>2016-06-09 15:39:57 +0000
committerChristophe Genevey Metat <genevey.christophe@gmail.com>2016-06-09 15:39:57 +0000
commit7c6eeca83081852d0eb323af94da3b2001357538 (patch)
tree7996e3f116025cb481b7ecd262b38769abc3c968 /src/my
parenta970e9d70979c0e378a009791dc9da6c029f8526 (diff)
downloadgnunet-7c6eeca83081852d0eb323af94da3b2001357538.tar.gz
gnunet-7c6eeca83081852d0eb323af94da3b2001357538.zip
fix memory leak
Diffstat (limited to 'src/my')
-rw-r--r--src/my/my.c24
-rw-r--r--src/my/my_query_helper.c128
-rw-r--r--src/my/my_result_helper.c79
-rw-r--r--src/my/test_my.c21
4 files changed, 98 insertions, 154 deletions
diff --git a/src/my/my.c b/src/my/my.c
index cec22716f..0328477be 100644
--- a/src/my/my.c
+++ b/src/my/my.c
@@ -42,7 +42,7 @@
42int 42int
43GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, 43GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc,
44 struct GNUNET_MYSQL_StatementHandle *sh, 44 struct GNUNET_MYSQL_StatementHandle *sh,
45 const struct GNUNET_MY_QueryParam *params) 45 struct GNUNET_MY_QueryParam *params)
46{ 46{
47 const struct GNUNET_MY_QueryParam *p; 47 const struct GNUNET_MY_QueryParam *p;
48 unsigned int num; 48 unsigned int num;
@@ -68,7 +68,6 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc,
68 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 68 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
69 "Conversion for MySQL query failed at offset %u\n", 69 "Conversion for MySQL query failed at offset %u\n",
70 i); 70 i);
71 GNUNET_MY_cleanup_query (params);
72 return GNUNET_SYSERR; 71 return GNUNET_SYSERR;
73 } 72 }
74 off += p->num_params; 73 off += p->num_params;
@@ -92,9 +91,11 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc,
92 "mysql_stmt_execute", __FILE__, __LINE__, 91 "mysql_stmt_execute", __FILE__, __LINE__,
93 mysql_stmt_error (stmt)); 92 mysql_stmt_error (stmt));
94 GNUNET_MYSQL_statements_invalidate (mc); 93 GNUNET_MYSQL_statements_invalidate (mc);
95 GNUNET_MY_cleanup_query (params);
96 return GNUNET_SYSERR; 94 return GNUNET_SYSERR;
97 } 95 }
96
97 GNUNET_MY_cleanup_query (params,
98 qbind);
98 } 99 }
99 100
100 return GNUNET_OK; 101 return GNUNET_OK;
@@ -108,13 +109,15 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc,
108 * @param qp query specification to clean up 109 * @param qp query specification to clean up
109 */ 110 */
110void 111void
111GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp) 112GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp,
113 MYSQL_BIND * qbind)
112{ 114{
113 unsigned int i; 115 unsigned int i;
114 116
115 for (i=0;NULL != qp[i].cleaner;i++) 117 for (i=0; NULL != qp[i].conv ;i++)
116 qp[i].cleaner (qp[i].conv_cls, 118 if(NULL != qp[i].cleaner)
117 &qp[i]); 119 qp[i].cleaner (qp[i].conv_cls,
120 &qbind[i]);
118} 121}
119 122
120 123
@@ -245,9 +248,10 @@ GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs)
245{ 248{
246 unsigned int i; 249 unsigned int i;
247 250
248 for (i=0;NULL != rs[i].cleaner;i++) 251 for (i=0;NULL != rs[i].post_conv;i++)
249 rs[i].cleaner (rs[i].conv_cls, 252 if (NULL != rs[i].cleaner)
250 &rs[i]); 253 rs[i].cleaner (rs[i].conv_cls,
254 &rs[i]);
251} 255}
252 256
253 257
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c
index cfa52b43a..c09422160 100644
--- a/src/my/my_query_helper.c
+++ b/src/my/my_query_helper.c
@@ -26,6 +26,22 @@
26#include <mysql/mysql.h> 26#include <mysql/mysql.h>
27#include "gnunet_my_lib.h" 27#include "gnunet_my_lib.h"
28 28
29
30/**
31 * Function called to clean up memory allocated
32 * by a #GNUNET_MY_QueryConverter.
33 *
34 * @param cls closure
35 * @param rd result data to clean up
36 */
37static void
38my_clean_query (void *cls,
39 MYSQL_BIND *qbind)
40{
41 GNUNET_free (qbind[0].buffer);
42}
43
44
29/** 45/**
30 * Function called to convert input argument into SQL parameters. 46 * Function called to convert input argument into SQL parameters.
31 * 47 *
@@ -84,6 +100,7 @@ GNUNET_MY_query_param_string (const char *ptr)
84 strlen(ptr)); 100 strlen(ptr));
85} 101}
86 102
103
87/** 104/**
88 * Function called to convert input argument into SQL parameters 105 * Function called to convert input argument into SQL parameters
89 * 106 *
@@ -107,7 +124,7 @@ my_conv_uint16 (void *cls,
107 if (NULL == u_nbo) 124 if (NULL == u_nbo)
108 return -1; 125 return -1;
109 126
110 *u_nbo = *u_hbo; 127 *u_nbo = *u_hbo;
111 128
112 qbind->buffer = (void *) u_nbo; 129 qbind->buffer = (void *) u_nbo;
113 qbind->buffer_length = sizeof(uint16_t); 130 qbind->buffer_length = sizeof(uint16_t);
@@ -116,6 +133,7 @@ my_conv_uint16 (void *cls,
116 return 1; 133 return 1;
117} 134}
118 135
136
119/** 137/**
120 * Generate query parameter for an uint16_t in host byte order. 138 * Generate query parameter for an uint16_t in host byte order.
121 * 139 *
@@ -126,7 +144,7 @@ GNUNET_MY_query_param_uint16 (const uint16_t *x)
126{ 144{
127 struct GNUNET_MY_QueryParam res = { 145 struct GNUNET_MY_QueryParam res = {
128 .conv = &my_conv_uint16, 146 .conv = &my_conv_uint16,
129 .cleaner = NULL, 147 .cleaner = &my_clean_query,
130 .conv_cls = NULL, 148 .conv_cls = NULL,
131 .num_params = 1, 149 .num_params = 1,
132 .data = x, 150 .data = x,
@@ -136,6 +154,7 @@ GNUNET_MY_query_param_uint16 (const uint16_t *x)
136 return res; 154 return res;
137} 155}
138 156
157
139/** 158/**
140 * Function called to convert input argument into SQL parameters 159 * Function called to convert input argument into SQL parameters
141 * 160 *
@@ -155,8 +174,8 @@ my_conv_uint32 (void *cls,
155 GNUNET_assert (1 == qp->num_params); 174 GNUNET_assert (1 == qp->num_params);
156 175
157 u_nbo = GNUNET_new (uint32_t); 176 u_nbo = GNUNET_new (uint32_t);
158// *u_nbo = htonl (*u_hbo); 177
159 *u_nbo = *u_hbo; 178 *u_nbo = *u_hbo;
160 179
161 qbind->buffer = (void *) u_nbo; 180 qbind->buffer = (void *) u_nbo;
162 qbind->buffer_length = sizeof(uint32_t); 181 qbind->buffer_length = sizeof(uint32_t);
@@ -165,6 +184,7 @@ my_conv_uint32 (void *cls,
165 return 1; 184 return 1;
166} 185}
167 186
187
168/** 188/**
169 * Generate query parameter for an uint32_t in host byte order 189 * Generate query parameter for an uint32_t in host byte order
170 * 190 *
@@ -175,7 +195,7 @@ GNUNET_MY_query_param_uint32 (const uint32_t *x)
175{ 195{
176 struct GNUNET_MY_QueryParam res = { 196 struct GNUNET_MY_QueryParam res = {
177 .conv = &my_conv_uint32, 197 .conv = &my_conv_uint32,
178 .cleaner = NULL, 198 .cleaner = &my_clean_query,
179 .conv_cls = NULL, 199 .conv_cls = NULL,
180 .num_params = 1, 200 .num_params = 1,
181 .data = x, 201 .data = x,
@@ -185,6 +205,7 @@ GNUNET_MY_query_param_uint32 (const uint32_t *x)
185 return res; 205 return res;
186} 206}
187 207
208
188/** 209/**
189 * Function called to convert input argument into SQL parameters 210 * Function called to convert input argument into SQL parameters
190 * 211 *
@@ -204,8 +225,8 @@ my_conv_uint64 (void *cls,
204 GNUNET_assert (1 == qp->num_params); 225 GNUNET_assert (1 == qp->num_params);
205 226
206 u_nbo = GNUNET_new(uint64_t); 227 u_nbo = GNUNET_new(uint64_t);
207 //*u_nbo = GNUNET_htonll (*u_hbo); 228
208 *u_nbo = *u_hbo; 229 *u_nbo = *u_hbo;
209 230
210 qbind->buffer = (void *) u_nbo; 231 qbind->buffer = (void *) u_nbo;
211 qbind->buffer_length = sizeof (uint64_t); 232 qbind->buffer_length = sizeof (uint64_t);
@@ -214,6 +235,7 @@ my_conv_uint64 (void *cls,
214 return 1; 235 return 1;
215} 236}
216 237
238
217/** 239/**
218 * Generate query parameter for an uint64_t in host byte order 240 * Generate query parameter for an uint64_t in host byte order
219 * 241 *
@@ -224,7 +246,7 @@ GNUNET_MY_query_param_uint64 (const uint64_t *x)
224{ 246{
225 struct GNUNET_MY_QueryParam res = { 247 struct GNUNET_MY_QueryParam res = {
226 .conv = &my_conv_uint64, 248 .conv = &my_conv_uint64,
227 .cleaner = NULL, 249 .cleaner = &my_clean_query,
228 .conv_cls = NULL, 250 .conv_cls = NULL,
229 .num_params = 1, 251 .num_params = 1,
230 .data = x, 252 .data = x,
@@ -234,6 +256,7 @@ GNUNET_MY_query_param_uint64 (const uint64_t *x)
234 return res; 256 return res;
235} 257}
236 258
259
237/** 260/**
238 * Function called to convert input argument into SQL parameters 261 * Function called to convert input argument into SQL parameters
239 * 262 *
@@ -246,57 +269,36 @@ static int
246my_conv_rsa_public_key (void *cls, 269my_conv_rsa_public_key (void *cls,
247 const struct GNUNET_MY_QueryParam *qp, 270 const struct GNUNET_MY_QueryParam *qp,
248 MYSQL_BIND * qbind) 271 MYSQL_BIND * qbind)
249 { 272{
250 const struct GNUNET_CRYPTO_RsaPublicKey *rsa = qp->data; 273 const struct GNUNET_CRYPTO_RsaPublicKey *rsa = qp->data;
251 char *buf; 274 char *buf;
252 size_t buf_size; 275 size_t buf_size;
253
254 GNUNET_assert(1 == qp->num_params);
255 // FIXME: this leaks memory right now...
256 buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa, &buf);
257
258 qbind->buffer = (void *) buf;
259 qbind->buffer_length = buf_size;
260 qbind->buffer_type = MYSQL_TYPE_BLOB;
261
262 return 1;
263 }
264 276
277 GNUNET_assert(1 == qp->num_params);
278 // FIXME: this leaks memory right now...
279 buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa, &buf);
265 280
266/** 281 qbind->buffer = (void *) buf;
267 * Function called to clean up memory allocated 282 qbind->buffer_length = buf_size;
268 * by a #GNUNET_MY_ResultConverter. 283 qbind->buffer_type = MYSQL_TYPE_BLOB;
269 *
270 * @param cls closure
271 * @param rd result data to clean up
272 */
273static void
274my_clean_rsa_public_key (void *cls,
275 struct GNUNET_MY_QueryParam *qp)
276{
277 struct GNUNET_CRYPTO_RsaPublicKey **pk = qp->data;
278 284
279 if (NULL != *pk) 285 return 1;
280 {
281 GNUNET_CRYPTO_rsa_public_key_free (*pk);
282 *pk = NULL;
283 }
284} 286}
285 287
286 288
287 /** 289/**
288 * Generate query parameter for an RSA public key. The 290 * Generate query parameter for an RSA public key. The
289 * database must contain a BLOB type in the respective position. 291 * database must contain a BLOB type in the respective position.
290 * 292 *
291 * @param x the query parameter to pass 293 * @param x the query parameter to pass
292 * @return array entry for the query parameters to use 294 * @return array entry for the query parameters to use
293 */ 295 */
294struct GNUNET_MY_QueryParam 296struct GNUNET_MY_QueryParam
295GNUNET_MY_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x) 297GNUNET_MY_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x)
296{ 298{
297 struct GNUNET_MY_QueryParam res = { 299 struct GNUNET_MY_QueryParam res = {
298 .conv = &my_conv_rsa_public_key, 300 .conv = &my_conv_rsa_public_key,
299 .cleaner = &my_clean_rsa_public_key, 301 .cleaner = &my_clean_query,
300 .conv_cls = NULL, 302 .conv_cls = NULL,
301 .num_params = 1, 303 .num_params = 1,
302 .data = x, 304 .data = x,
@@ -312,7 +314,7 @@ GNUNET_MY_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x
312 * 314 *
313 *@param cls closure 315 *@param cls closure
314 *@param pq data about the query 316 *@param pq data about the query
315 * @param qbind array of parameters to initialize 317 *@param qbind array of parameters to initialize
316 *@return -1 on error 318 *@return -1 on error
317 */ 319 */
318static int 320static int
@@ -337,27 +339,6 @@ my_conv_rsa_signature (void *cls,
337 339
338 340
339/** 341/**
340 * Function called to clean up memory allocated
341 * by a #GNUNET_MY_QueryConverter.
342 *
343 * @param cls closure
344 * @param rd result data to clean up
345 */
346static void
347my_clean_rsa_signature (void *cls,
348 struct GNUNET_MY_QueryParam *qp)
349{
350 struct GNUNET_CRYPTO_RsaSignature **sig = qp->data;
351
352 if (NULL != *sig)
353 {
354 GNUNET_CRYPTO_rsa_signature_free (*sig);
355 *sig = NULL;
356 }
357}
358
359
360/**
361 * Generate query parameter for an RSA signature. The 342 * Generate query parameter for an RSA signature. The
362 * database must contain a BLOB type in the respective position 343 * database must contain a BLOB type in the respective position
363 * 344 *
@@ -369,7 +350,7 @@ GNUNET_MY_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x)
369{ 350{
370 struct GNUNET_MY_QueryParam res = { 351 struct GNUNET_MY_QueryParam res = {
371 .conv = &my_conv_rsa_signature, 352 .conv = &my_conv_rsa_signature,
372 .cleaner = &my_clean_rsa_signature, 353 .cleaner = &my_clean_query,
373 .conv_cls = NULL, 354 .conv_cls = NULL,
374 .num_params = 1, 355 .num_params = 1,
375 .data = (x), 356 .data = (x),
@@ -378,6 +359,7 @@ GNUNET_MY_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x)
378 return res; 359 return res;
379} 360}
380 361
362
381/** 363/**
382 * Generate query parameter for an absolute time value. 364 * Generate query parameter for an absolute time value.
383 * The database must store a 64-bit integer. 365 * The database must store a 64-bit integer.
@@ -391,6 +373,7 @@ GNUNET_MY_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x)
391 return GNUNET_MY_query_param_uint64 (&x->abs_value_us); 373 return GNUNET_MY_query_param_uint64 (&x->abs_value_us);
392} 374}
393 375
376
394/** 377/**
395 * Generate query parameter for an absolute time value. 378 * Generate query parameter for an absolute time value.
396 * The database must store a 64-bit integer. 379 * The database must store a 64-bit integer.
@@ -403,4 +386,5 @@ GNUNET_MY_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x
403 return GNUNET_MY_query_param_auto_from_type (&x->abs_value_us__); 386 return GNUNET_MY_query_param_auto_from_type (&x->abs_value_us__);
404} 387}
405 388
406/* end of my_query_helper.c */ 389
390/* end of my_query_helper.c */ \ No newline at end of file
diff --git a/src/my/my_result_helper.c b/src/my/my_result_helper.c
index 6f1b27065..9c04b9bed 100644
--- a/src/my/my_result_helper.c
+++ b/src/my/my_result_helper.c
@@ -74,14 +74,13 @@ post_extract_varsize_blob (void *cls,
74 74
75 if (rs->mysql_bind_output_length != size) 75 if (rs->mysql_bind_output_length != size)
76 return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ 76 return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */
77
77 buf = GNUNET_malloc (size); 78 buf = GNUNET_malloc (size);
78 79
79 results[0].buffer = buf; 80 results[0].buffer = buf;
80 results[0].buffer_length = size; 81 results[0].buffer_length = size;
81 results[0].buffer_type = MYSQL_TYPE_BLOB; 82 results[0].buffer_type = MYSQL_TYPE_BLOB;
82 83
83 fprintf(stderr, "size : %d\n", size);
84
85 if (0 != 84 if (0 !=
86 mysql_stmt_fetch_column (stmt, 85 mysql_stmt_fetch_column (stmt,
87 results, 86 results,
@@ -92,8 +91,6 @@ post_extract_varsize_blob (void *cls,
92 return GNUNET_SYSERR; 91 return GNUNET_SYSERR;
93 } 92 }
94 93
95 printf("buf : %s\n", (char*)buf);
96
97 *(void **) rs->dst = buf; 94 *(void **) rs->dst = buf;
98 *rs->result_size = size; 95 *rs->result_size = size;
99 96
@@ -111,16 +108,14 @@ static void
111cleanup_varsize_blob (void *cls, 108cleanup_varsize_blob (void *cls,
112 struct GNUNET_MY_ResultSpec *rs) 109 struct GNUNET_MY_ResultSpec *rs)
113{ 110{
114 void *ptr; 111 void **ptr = (void **)rs->dst;
115
116 ptr = * (void **) rs->dst;
117 if (NULL == ptr)
118 return;
119 GNUNET_free (ptr);
120 *(void **) rs->dst = NULL;
121 *rs->result_size = 0;
122}
123 112
113 if (NULL != *ptr)
114 {
115 GNUNET_free (*ptr);
116 *ptr = NULL;
117 }
118}
124 119
125/** 120/**
126 * Variable-size result expected 121 * Variable-size result expected
@@ -219,6 +214,7 @@ GNUNET_MY_result_spec_fixed_size (void *ptr,
219 { 214 {
220 .pre_conv = &pre_extract_fixed_blob, 215 .pre_conv = &pre_extract_fixed_blob,
221 .post_conv = &post_extract_fixed_blob, 216 .post_conv = &post_extract_fixed_blob,
217 .cleaner = NULL,
222 .dst = (void *)(ptr), 218 .dst = (void *)(ptr),
223 .dst_size = ptr_size, 219 .dst_size = ptr_size,
224 .num_fields = 1 220 .num_fields = 1
@@ -508,31 +504,8 @@ pre_extract_string (void * cls,
508 results[0].buffer = (char *)rs->dst; 504 results[0].buffer = (char *)rs->dst;
509 results[0].buffer_length = rs->dst_size; 505 results[0].buffer_length = rs->dst_size;
510 results[0].length = &rs->mysql_bind_output_length; 506 results[0].length = &rs->mysql_bind_output_length;
511/* 507
512 char **str = rs->dst; 508 return GNUNET_OK;
513 size_t len;
514 const char *res;
515
516 *str = NULL;
517
518 if (results->is_null)
519 {
520 return GNUNET_SYSERR;
521 }
522
523 len = results->buffer_length;
524 res = results->buffer;
525
526 *str = GNUNET_strndup (res,
527 len);
528
529 if (NULL == *str)
530 {
531 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
532 "Results contains bogus value (fail to decode)\n");
533 return GNUNET_SYSERR;
534 }
535*/ return GNUNET_OK;
536} 509}
537 510
538 511
@@ -559,32 +532,6 @@ post_extract_string (void * cls,
559 if (rs->dst_size != rs->mysql_bind_output_length) 532 if (rs->dst_size != rs->mysql_bind_output_length)
560 return GNUNET_SYSERR; 533 return GNUNET_SYSERR;
561 return GNUNET_OK; 534 return GNUNET_OK;
562/*
563 char **str = rs->dst;
564 size_t len;
565 const char *res;
566
567 *str = NULL;
568
569 if (results->is_null)
570 {
571 return GNUNET_SYSERR;
572 }
573
574 len = results->buffer_length;
575 res = results->buffer;
576
577 *str = GNUNET_strndup (res,
578 len);
579
580 if (NULL == *str)
581 {
582 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
583 "Results contains bogus value (fail to decode)\n");
584 return GNUNET_SYSERR;
585 }
586 return GNUNET_OK;
587*/
588} 535}
589 536
590 537
@@ -600,6 +547,7 @@ GNUNET_MY_result_spec_string (char **dst)
600 struct GNUNET_MY_ResultSpec res = { 547 struct GNUNET_MY_ResultSpec res = {
601 .pre_conv = &pre_extract_string, 548 .pre_conv = &pre_extract_string,
602 .post_conv = &post_extract_string, 549 .post_conv = &post_extract_string,
550 .cleaner = NULL,
603 .dst = (void *) dst, 551 .dst = (void *) dst,
604 .dst_size = 0, 552 .dst_size = 0,
605 .num_fields = 1 553 .num_fields = 1
@@ -704,6 +652,7 @@ GNUNET_MY_result_spec_uint16 (uint16_t *u16)
704 struct GNUNET_MY_ResultSpec res = { 652 struct GNUNET_MY_ResultSpec res = {
705 .pre_conv = &pre_extract_uint16, 653 .pre_conv = &pre_extract_uint16,
706 .post_conv = &post_extract_uint16, 654 .post_conv = &post_extract_uint16,
655 .cleaner = NULL,
707 .dst = (void *) u16, 656 .dst = (void *) u16,
708 .dst_size = sizeof (*u16), 657 .dst_size = sizeof (*u16),
709 .num_fields = 1 658 .num_fields = 1
@@ -778,6 +727,7 @@ GNUNET_MY_result_spec_uint32 (uint32_t *u32)
778 struct GNUNET_MY_ResultSpec res = { 727 struct GNUNET_MY_ResultSpec res = {
779 .pre_conv = &pre_extract_uint32, 728 .pre_conv = &pre_extract_uint32,
780 .post_conv = &post_extract_uint32, 729 .post_conv = &post_extract_uint32,
730 .cleaner = NULL,
781 .dst = (void *) u32, 731 .dst = (void *) u32,
782 .dst_size = sizeof (*u32), 732 .dst_size = sizeof (*u32),
783 .num_fields = 1 733 .num_fields = 1
@@ -854,6 +804,7 @@ GNUNET_MY_result_spec_uint64 (uint64_t *u64)
854 struct GNUNET_MY_ResultSpec res = { 804 struct GNUNET_MY_ResultSpec res = {
855 .pre_conv = &pre_extract_uint64, 805 .pre_conv = &pre_extract_uint64,
856 .post_conv = &post_extract_uint64, 806 .post_conv = &post_extract_uint64,
807 .cleaner = NULL,
857 .dst = (void *) u64, 808 .dst = (void *) u64,
858 .dst_size = sizeof (*u64), 809 .dst_size = sizeof (*u64),
859 .num_fields = 1 810 .num_fields = 1
diff --git a/src/my/test_my.c b/src/my/test_my.c
index f7e6ae68a..defaf6cbc 100644
--- a/src/my/test_my.c
+++ b/src/my/test_my.c
@@ -37,9 +37,9 @@
37static int 37static int
38run_queries (struct GNUNET_MYSQL_Context *context) 38run_queries (struct GNUNET_MYSQL_Context *context)
39{ 39{
40 struct GNUNET_CRYPTO_RsaPublicKey *pub; 40 struct GNUNET_CRYPTO_RsaPublicKey *pub = NULL;
41 struct GNUNET_CRYPTO_RsaPublicKey *pub2 = NULL; 41 struct GNUNET_CRYPTO_RsaPublicKey *pub2 = NULL;
42 struct GNUNET_CRYPTO_RsaSignature *sig; 42 struct GNUNET_CRYPTO_RsaSignature *sig = NULL;;
43 struct GNUNET_CRYPTO_RsaSignature *sig2 = NULL; 43 struct GNUNET_CRYPTO_RsaSignature *sig2 = NULL;
44 struct GNUNET_TIME_Absolute abs_time = GNUNET_TIME_absolute_get (); 44 struct GNUNET_TIME_Absolute abs_time = GNUNET_TIME_absolute_get ();
45 struct GNUNET_TIME_Absolute abs_time2; 45 struct GNUNET_TIME_Absolute abs_time2;
@@ -48,7 +48,7 @@ run_queries (struct GNUNET_MYSQL_Context *context)
48 struct GNUNET_HashCode hc; 48 struct GNUNET_HashCode hc;
49 struct GNUNET_HashCode hc2; 49 struct GNUNET_HashCode hc2;
50 const char msg[] = "hello"; 50 const char msg[] = "hello";
51 void *msg2; 51 void *msg2 = NULL;;
52 size_t msg2_len; 52 size_t msg2_len;
53 53
54 uint16_t u16; 54 uint16_t u16;
@@ -60,10 +60,10 @@ run_queries (struct GNUNET_MYSQL_Context *context)
60 60
61 int ret; 61 int ret;
62 62
63 struct GNUNET_MYSQL_StatementHandle *statements_handle_insert; 63 struct GNUNET_MYSQL_StatementHandle *statements_handle_insert = NULL;
64 struct GNUNET_MYSQL_StatementHandle *statements_handle_select; 64 struct GNUNET_MYSQL_StatementHandle *statements_handle_select = NULL;
65 65
66 struct GNUNET_CRYPTO_RsaPrivateKey *priv; 66 struct GNUNET_CRYPTO_RsaPrivateKey *priv = NULL;
67 struct GNUNET_HashCode hmsg; 67 struct GNUNET_HashCode hmsg;
68 68
69 priv = GNUNET_CRYPTO_rsa_private_key_create (1024); 69 priv = GNUNET_CRYPTO_rsa_private_key_create (1024);
@@ -163,7 +163,7 @@ run_queries (struct GNUNET_MYSQL_Context *context)
163 ret = GNUNET_MY_extract_result (statements_handle_select, 163 ret = GNUNET_MY_extract_result (statements_handle_select,
164 results_select); 164 results_select);
165 165
166 GNUNET_break (GNUNET_YES == ret); 166 GNUNET_assert (GNUNET_YES == ret);
167 GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us); 167 GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us);
168 GNUNET_break (forever.abs_value_us == forever2.abs_value_us); 168 GNUNET_break (forever.abs_value_us == forever2.abs_value_us);
169 GNUNET_break (0 == 169 GNUNET_break (0 ==
@@ -171,6 +171,8 @@ run_queries (struct GNUNET_MYSQL_Context *context)
171 &hc2, 171 &hc2,
172 sizeof (struct GNUNET_HashCode))); 172 sizeof (struct GNUNET_HashCode)));
173 173
174 GNUNET_assert (NULL != sig2);
175 GNUNET_assert (NULL != pub2);
174 GNUNET_break (0 == 176 GNUNET_break (0 ==
175 GNUNET_CRYPTO_rsa_signature_cmp (sig, 177 GNUNET_CRYPTO_rsa_signature_cmp (sig,
176 sig2)); 178 sig2));
@@ -192,7 +194,7 @@ run_queries (struct GNUNET_MYSQL_Context *context)
192 GNUNET_CRYPTO_rsa_signature_free (sig); 194 GNUNET_CRYPTO_rsa_signature_free (sig);
193 GNUNET_CRYPTO_rsa_private_key_free (priv); 195 GNUNET_CRYPTO_rsa_private_key_free (priv);
194 GNUNET_CRYPTO_rsa_public_key_free (pub); 196 GNUNET_CRYPTO_rsa_public_key_free (pub);
195 197
196 if (GNUNET_OK != ret) 198 if (GNUNET_OK != ret)
197 return 1; 199 return 1;
198 200
@@ -251,5 +253,8 @@ main (int argc, const char * const argv[])
251 253
252 ret = run_queries (context); 254 ret = run_queries (context);
253 255
256 GNUNET_MYSQL_context_destroy (context);
257 GNUNET_free (config);
258
254 return ret; 259 return ret;
255} 260}