summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-05-15 18:46:35 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-05-15 18:46:35 +0200
commit168e501991b9506b588e1180527dad9c9662ae0c (patch)
treed97f3376663571e297a2ef81ddc7d32a37cbfd77
parent60635a4887062fbcea6b5a8635a73bdadc20d5bc (diff)
-coverity: use after free
-rw-r--r--src/datacache/plugin_datacache_sqlite.c3
-rw-r--r--src/datastore/datastore_api.c2
-rw-r--r--src/datastore/gnunet-service-datastore.c6
-rw-r--r--src/datastore/plugin_datastore_sqlite.c3
4 files changed, 9 insertions, 5 deletions
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c
index a7da6b068..bade15479 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -764,7 +764,8 @@ libgnunet_plugin_datacache_sqlite_done (void *cls)
#if ! WINDOWS || defined(__CYGWIN__)
if ((NULL != plugin->fn) && (0 != unlink (plugin->fn)))
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", plugin->fn);
- GNUNET_free (plugin->fn);
+ if (NULL != plugin->fn)
+ GNUNET_free (plugin->fn);
#endif
sqlite3_finalize (plugin->insert_stmt);
sqlite3_finalize (plugin->get_count_stmt);
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index d658b9c85..cb21c9308 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -1430,7 +1430,7 @@ GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h,
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Could not queue request for `%s'\n",
- GNUNET_h2s (key));
+ (NULL == key) ? "NULL" : GNUNET_h2s (key));
return NULL;
}
#if INSANE_STATISTICS
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 97888ce03..7d07ba3b3 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -1556,7 +1556,8 @@ run (void *cls,
5); /* approx. 3% false positives at max use */
refresh_bf = GNUNET_YES;
}
- GNUNET_free (pfn);
+ if (NULL != pfn)
+ GNUNET_free (pfn);
}
else
{
@@ -1566,7 +1567,8 @@ run (void *cls,
5); /* approx. 3% false positives at max use */
refresh_bf = GNUNET_YES;
}
- GNUNET_free (fn);
+ if (NULL != fn)
+ GNUNET_free (fn);
if (NULL == filter)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index f58955b7b..40f955312 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -729,7 +729,8 @@ sqlite_plugin_put (void *cls,
}
GNUNET_SQ_reset (plugin->dbh, stmt);
cont (cont_cls, key, size, ret, msg);
- GNUNET_free (msg);
+ if (NULL != msg)
+ GNUNET_free (msg);
}