diff options
author | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-06-09 15:39:57 +0000 |
---|---|---|
committer | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-06-09 15:39:57 +0000 |
commit | 7c6eeca83081852d0eb323af94da3b2001357538 (patch) | |
tree | 7996e3f116025cb481b7ecd262b38769abc3c968 /src/my/my.c | |
parent | a970e9d70979c0e378a009791dc9da6c029f8526 (diff) | |
download | gnunet-7c6eeca83081852d0eb323af94da3b2001357538.tar.gz gnunet-7c6eeca83081852d0eb323af94da3b2001357538.zip |
fix memory leak
Diffstat (limited to 'src/my/my.c')
-rw-r--r-- | src/my/my.c | 24 |
1 files changed, 14 insertions, 10 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 @@ | |||
42 | int | 42 | int |
43 | GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | 43 | GNUNET_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 | */ |
110 | void | 111 | void |
111 | GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp) | 112 | GNUNET_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 | ||