From af219c4cff61abd088f89c8a5029af1d449a78b6 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Thu, 7 Jul 2016 12:35:25 +0000 Subject: [PATCH] -coverity --- src/peerstore/plugin_peerstore_flat.c | 7 +++++-- 1 file 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"); -- 2.25.1