libnm: fix clearing memory in file_to_secure_bytes()

If we go through the lengths of clearing the allocated
memory, we must not forget @contents.

(cherry picked from commit 88a79625a6)
This commit is contained in:
Thomas Haller 2015-02-26 02:28:52 +01:00
parent fa5a6caf2b
commit ef3cd489e1

View file

@ -1755,7 +1755,7 @@ file_to_secure_bytes (const char *filename)
if (g_file_get_contents (filename, &contents, &length, NULL)) {
array = g_byte_array_sized_new (length);
g_byte_array_append (array, (guint8 *) contents, length);
g_assert (array->len == length);
memset (contents, 0, length);
g_free (contents);
return g_bytes_new_with_free_func (array->data, array->len, free_secure_bytes, array);
}