Commit cb9ee701 authored by Philip Withnall's avatar Philip Withnall
Browse files

gkeyfilesettingsbackend: Fix basename handling when group is unset

Fix an effective regression in commit
7781a9cb, which happens when
`convert_path()` is called with a `key` which contains no slashes. In
that case, the `key` is entirely the `basename`.

Prior to commit 7781a9cb

, the code worked through a fluke of `i == -1`
cancelling out with the various additions in the `g_memdup()` call, and
effectively resulting in `g_strdup (key)`.

Spotted by Guido Berhoerster.
Signed-off-by: Philip Withnall's avatarPhilip Withnall <pwithnall@endlessos.org>
parent 00b181fa
......@@ -185,7 +185,12 @@ convert_path (GKeyfileSettingsBackend *kfsb,
}
if (basename)
*basename = g_memdup2 (last_slash + 1, key_len - (last_slash - key));
{
if (last_slash != NULL)
*basename = g_memdup2 (last_slash + 1, key_len - (last_slash - key));
else
*basename = g_strdup (key);
}
return TRUE;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment