[PATCH] keyfile: include '\0' when copying string to array



This commit fixes the corrupted string in the copied array by
including '\0' in the orignal string.
---
 src/settings/plugins/keyfile/reader.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c
index c4136e0..451d01c 100644
--- a/src/settings/plugins/keyfile/reader.c
+++ b/src/settings/plugins/keyfile/reader.c
@@ -759,8 +759,8 @@ get_uchar_array (GKeyFile *keyfile,
 		g_regex_unref (regex);
 
 		if (new_format) {
-			array = g_byte_array_sized_new (strlen (tmp_string));
-			g_byte_array_append (array, (guint8 *) tmp_string, strlen (tmp_string));
+			array = g_byte_array_sized_new (strlen (tmp_string) + 1);
+			g_byte_array_append (array, (guint8 *) tmp_string, strlen (tmp_string) + 1);
 		}
 		g_free (tmp_string);
 	}
-- 
1.7.3.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]