From b19b0808940c8c54b102012be134a370b26e348e Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 5 Feb 2014 16:25:06 +0100 Subject: Update bundled libxkbcommon version to 0.4.0 This release comes with important bug fixes. Also we can now remove the workaround code which was needed for libxkbcommon 0.2.0. Task-number: QTBUG-31712 Task-number: QTBUG-33732 Task-number: QTBUG-34056 Change-Id: I57caf7f803b9a01a15541a5ad82e464de3b8abbb Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/3rdparty/xkbcommon/src/xkbcomp/include.c | 36 +++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'src/3rdparty/xkbcommon/src/xkbcomp/include.c') diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/include.c b/src/3rdparty/xkbcommon/src/xkbcomp/include.c index b4a4014635..dc3f1e49bd 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/include.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/include.c @@ -199,17 +199,34 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name, { unsigned int i; FILE *file = NULL; - char buf[PATH_MAX]; + char *buf = NULL; const char *typeDir; + size_t buf_size = 0, typeDirLen, name_len; typeDir = DirectoryForInclude(type); + typeDirLen = strlen(typeDir); + name_len = strlen(name); for (i = 0; i < xkb_context_num_include_paths(ctx); i++) { - int ret = snprintf(buf, sizeof(buf), "%s/%s/%s", - xkb_context_include_path_get(ctx, i), - typeDir, name); - if (ret >= (ssize_t) sizeof(buf)) { - log_err(ctx, "File name (%s/%s/%s) too long\n", + size_t new_buf_size = strlen(xkb_context_include_path_get(ctx, i)) + + typeDirLen + name_len + 3; + int ret; + if (new_buf_size > buf_size) { + void *buf_new = realloc(buf, new_buf_size); + if (buf_new) { + buf_size = new_buf_size; + buf = buf_new; + } else { + log_err(ctx, "Cannot realloc for name (%s/%s/%s)\n", + xkb_context_include_path_get(ctx, i), typeDir, name); + continue; + } + } + ret = snprintf(buf, buf_size, "%s/%s/%s", + xkb_context_include_path_get(ctx, i), + typeDir, name); + if (ret < 0) { + log_err(ctx, "snprintf error (%s/%s/%s)\n", xkb_context_include_path_get(ctx, i), typeDir, name); continue; } @@ -242,11 +259,14 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name, xkb_context_failed_include_path_get(ctx, i)); } + free(buf); return NULL; } if (pathRtrn) - *pathRtrn = strdup(buf); + *pathRtrn = buf; + else + free(buf); return file; } @@ -275,7 +295,7 @@ ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt, if (xkb_file->file_type != file_type) { log_err(ctx, - "Include file wrong type (expected %s, got %s); " + "Include file of wrong type (expected %s, got %s); " "Include file \"%s\" ignored\n", xkb_file_type_to_string(file_type), xkb_file_type_to_string(xkb_file->file_type), stmt->file); -- cgit v1.2.3