summaryrefslogtreecommitdiff
path: root/src/peerstore/plugin_peerstore_flat.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2016-07-07 12:35:25 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2016-07-07 12:35:25 +0000
commitaf219c4cff61abd088f89c8a5029af1d449a78b6 (patch)
tree2db9b452f0de5a29e4275d902e193af4ec49f501 /src/peerstore/plugin_peerstore_flat.c
parentf7a8e0e05cb1edadb195a311c7a4c58a6bd0daa9 (diff)
-coverity
Diffstat (limited to 'src/peerstore/plugin_peerstore_flat.c')
-rw-r--r--src/peerstore/plugin_peerstore_flat.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/peerstore/plugin_peerstore_flat.c b/src/peerstore/plugin_peerstore_flat.c
index 5ffabed8f..fd417be05 100644
--- a/src/peerstore/plugin_peerstore_flat.c
+++ b/src/peerstore/plugin_peerstore_flat.c
@@ -394,7 +394,7 @@ database_setup (struct Plugin *plugin)
return GNUNET_SYSERR;
}
- buffer = GNUNET_malloc (size);
+ buffer = GNUNET_malloc (size) + 1;
if (GNUNET_SYSERR == GNUNET_DISK_file_read (fh,
buffer,
@@ -403,9 +403,12 @@ database_setup (struct Plugin *plugin)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Unable to read file: %s.\n"),
afsdir);
+ GNUNET_DISK_file_close (fh);
+ GNUNET_free (buffer);
return GNUNET_SYSERR;
}
-
+
+ buffer[size] = '\0';
GNUNET_DISK_file_close (fh);
if (0 < size) {
line = strtok (buffer, "\n");