[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 03/04: fix memory leaks (db test)
From: |
gnunet |
Subject: |
[taler-anastasis] 03/04: fix memory leaks (db test) |
Date: |
Wed, 21 Oct 2020 15:36:45 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit 5968c0fe0c8c7c9037fd5e929c007ac6e08e7bfc
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Wed Oct 21 15:35:29 2020 +0200
fix memory leaks (db test)
---
src/stasis/anastasis_db_plugin.c | 2 +-
src/stasis/plugin_anastasis_postgres.c | 55 +++++++++++++++-------------------
src/stasis/test_anastasis_db.c | 9 ++++--
3 files changed, 31 insertions(+), 35 deletions(-)
diff --git a/src/stasis/anastasis_db_plugin.c b/src/stasis/anastasis_db_plugin.c
index 8708cfb..db46ab8 100644
--- a/src/stasis/anastasis_db_plugin.c
+++ b/src/stasis/anastasis_db_plugin.c
@@ -60,7 +60,7 @@ ANASTASIS_DB_plugin_load (const struct
GNUNET_CONFIGURATION_Handle *cfg)
if (NULL != plugin)
plugin->library_name = lib_name;
else
- GNUNET_free (lib_name);
+ lib_name = NULL;
GNUNET_CONFIGURATION_destroy (cfg_dup);
return plugin;
}
diff --git a/src/stasis/plugin_anastasis_postgres.c
b/src/stasis/plugin_anastasis_postgres.c
index e481194..8a68c96 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -457,7 +457,6 @@ postgres_store_recovery_document (void *cls,
rollback (pg);
return qs;
case ANASTASIS_DB_STATUS_SOFT_ERROR:
- // FIXME: or: retry internally?
rollback (pg);
return qs;
case ANASTASIS_DB_STATUS_NO_RESULTS:
@@ -474,12 +473,6 @@ postgres_store_recovery_document (void *cls,
/* First, check if account exists */
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d Public key used to query db is: %s\n",
- __FILE__,
- __LINE__,
- TALER_B2S (anastasis_pub));
-
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
GNUNET_PQ_query_param_end
@@ -601,6 +594,7 @@ postgres_store_recovery_document (void *cls,
}
/* check if existing recovery_data conflicts */
+ if (*version > 1)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"At %s:%d Public key used to query db is: %s\n",
@@ -622,31 +616,30 @@ postgres_store_recovery_document (void *cls,
"recoverydocument_select_hash",
params,
rs);
+ switch (qs)
+ {
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ return ANASTASIS_DB_STATUS_HARD_ERROR;
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ GNUNET_break (0);
+ return ANASTASIS_DB_STATUS_SOFT_ERROR;
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ /* original error must have been a hard error, oddly enough */
+ // return ANASTASIS_DB_STATUS_HARD_ERROR;
+ break;
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ /* handle interesting case below */
+ break;
+ default:
+ GNUNET_break (0);
+ return ANASTASIS_DB_STATUS_HARD_ERROR;
+ }
+ /* had an existing recovery_data, is it identical? */
+ if (0 == GNUNET_memcmp (&dh,
+ recovery_data_hash))
+ /* previous conflicting recovery_data exists */
+ return ANASTASIS_DB_STATUS_OLD_RECOVERY_UPLOAD_MISSMATCH;
}
- switch (qs)
- {
- case GNUNET_DB_STATUS_HARD_ERROR:
- return ANASTASIS_DB_STATUS_HARD_ERROR;
- case GNUNET_DB_STATUS_SOFT_ERROR:
- GNUNET_break (0);
- return ANASTASIS_DB_STATUS_SOFT_ERROR;
- case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
- /* original error must have been a hard error, oddly enough */
- // return ANASTASIS_DB_STATUS_HARD_ERROR;
- break;
- case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
- /* handle interesting case below */
- break;
- default:
- GNUNET_break (0);
- return ANASTASIS_DB_STATUS_HARD_ERROR;
- }
- /* had an existing recovery_data, is it identical? */
- if (0 == GNUNET_memcmp (&dh,
- recovery_data_hash))
- /* previous conflicting recovery_data exists */
- return ANASTASIS_DB_STATUS_OLD_RECOVERY_UPLOAD_MISSMATCH;
-
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
diff --git a/src/stasis/test_anastasis_db.c b/src/stasis/test_anastasis_db.c
index daa4b07..0a6df85 100644
--- a/src/stasis/test_anastasis_db.c
+++ b/src/stasis/test_anastasis_db.c
@@ -284,10 +284,13 @@ run (void *cls)
result = 0;
drop:
-/* GNUNET_break (GNUNET_OK ==
- plugin->drop_tables (plugin->cls));*/
+ GNUNET_break (GNUNET_OK ==
+ plugin->drop_tables (plugin->cls));
ANASTASIS_DB_plugin_unload (plugin);
- plugin = NULL;
+ if (NULL != plugin)
+ {
+ plugin = NULL;
+ }
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.