summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2021-02-10 21:16:39 +0000
committerPhilip Withnall <pwithnall@endlessos.org>2021-02-10 21:16:39 +0000
commit9d27c57f7035a6bb977070abadacfa479a0237d9 (patch)
tree9805653fd676e7237da5a9ebd3b2a29073c5eb95
parent206ebfbff60bd6be5208a8a25f7cb912a3d27311 (diff)
downloadglib-9d27c57f7035a6bb977070abadacfa479a0237d9.tar.gz
gkeyfilesettingsbackend: Fix basename handling when group is unset
Fix an effective regression in commit 7781a9cbd2fd0aa84bee0f4eee88470640ff6706, 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 <pwithnall@endlessos.org>
-rw-r--r--gio/gkeyfilesettingsbackend.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c
index 793eed02a..d57a9d421 100644
--- a/gio/gkeyfilesettingsbackend.c
+++ b/gio/gkeyfilesettingsbackend.c
@@ -188,7 +188,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;
}