summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2021-03-19 09:49:24 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2023-05-04 18:46:16 +1000
commit8b7c1850e15192b6550a264eace3069b4350a6e9 (patch)
tree5b2ba2ae7aa6e6b39975c7faa270279bae848909
parenta50890b155e37d4347b1ec238ec998e6ad19476d (diff)
downloadxorg-lib-libxkbcommon-8b7c1850e15192b6550a264eace3069b4350a6e9.tar.gz
registry: remove a few asprintf/free() calls with snprintf
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/registry.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/registry.c b/src/registry.c
index e23e87b..d6181e1 100644
--- a/src/registry.c
+++ b/src/registry.c
@@ -594,7 +594,7 @@ XKB_EXPORT bool
rxkb_context_include_path_append_default(struct rxkb_context *ctx)
{
const char *home, *xdg, *root, *extra;
- char *user_path;
+ char user_path[PATH_MAX];
bool ret = false;
if (ctx->context_state != CONTEXT_NEW) {
@@ -606,26 +606,17 @@ rxkb_context_include_path_append_default(struct rxkb_context *ctx)
xdg = rxkb_context_getenv(ctx, "XDG_CONFIG_HOME");
if (xdg != NULL) {
- user_path = asprintf_safe("%s/xkb", xdg);
- if (user_path) {
+ if (snprintf_safe(user_path, sizeof(user_path), "%s/xkb", xdg))
ret |= rxkb_context_include_path_append(ctx, user_path);
- free(user_path);
- }
} else if (home != NULL) {
/* XDG_CONFIG_HOME fallback is $HOME/.config/ */
- user_path = asprintf_safe("%s/.config/xkb", home);
- if (user_path) {
+ if (snprintf_safe(user_path, sizeof(user_path), "%s/.config/xkb", home))
ret |= rxkb_context_include_path_append(ctx, user_path);
- free(user_path);
- }
}
if (home != NULL) {
- user_path = asprintf_safe("%s/.xkb", home);
- if (user_path) {
+ if (snprintf_safe(user_path, sizeof(user_path), "%s/.xkb", home))
ret |= rxkb_context_include_path_append(ctx, user_path);
- free(user_path);
- }
}
extra = rxkb_context_getenv(ctx, "XKB_CONFIG_EXTRA_PATH");