aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/plugin_peerstore_flat.c
diff options
context:
space:
mode:
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)
394 return GNUNET_SYSERR; 394 return GNUNET_SYSERR;
395 } 395 }
396 396
397 buffer = GNUNET_malloc (size); 397 buffer = GNUNET_malloc (size) + 1;
398 398
399 if (GNUNET_SYSERR == GNUNET_DISK_file_read (fh, 399 if (GNUNET_SYSERR == GNUNET_DISK_file_read (fh,
400 buffer, 400 buffer,
@@ -403,9 +403,12 @@ database_setup (struct Plugin *plugin)
403 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 403 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
404 _("Unable to read file: %s.\n"), 404 _("Unable to read file: %s.\n"),
405 afsdir); 405 afsdir);
406 GNUNET_DISK_file_close (fh);
407 GNUNET_free (buffer);
406 return GNUNET_SYSERR; 408 return GNUNET_SYSERR;
407 } 409 }
408 410
411 buffer[size] = '\0';
409 GNUNET_DISK_file_close (fh); 412 GNUNET_DISK_file_close (fh);
410 if (0 < size) { 413 if (0 < size) {
411 line = strtok (buffer, "\n"); 414 line = strtok (buffer, "\n");