libnm-keyfile: ensure g_key_file_get_groups() sets the length argument

Under certain cases, if g_key_file_get_groups() fails, it might not set the
out argument @length. Play it safe and initialize it.

(cherry picked from commit aa7a53bc67)
This commit is contained in:
Thomas Haller 2015-06-25 15:36:43 +02:00
parent 53dcdf8516
commit 519ea3f0d4

View file

@ -1577,6 +1577,8 @@ nm_keyfile_read (GKeyFile *keyfile,
info.user_data = user_data;
groups = g_key_file_get_groups (keyfile, &length);
if (!groups)
length = 0;
for (i = 0; i < length; i++) {
/* Only read out secrets when needed */
if (!strcmp (groups[i], VPN_SECRETS_GROUP)) {