diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-03-24 16:10:15 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-03-24 16:10:15 +0100 |
commit | 3b5c0bc0780f1749fed7c07bd8b691400a0282b7 (patch) | |
tree | 1022f5553ad5a0aca9b5f3b49ca38a01c2329d20 /src/3rdparty/xkbcommon/src/xkbcomp/include.c | |
parent | c79918733a194ebbe5a2fe1617c884659f3e4b9f (diff) | |
parent | 21f1738a94fc8544ece04b3b1ee03a11986fe59b (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/gui/image/qjpeghandler.cpp
Change-Id: I9db3acea7d5c82f5da679c8eaeb29431136665f0
Diffstat (limited to 'src/3rdparty/xkbcommon/src/xkbcomp/include.c')
-rw-r--r-- | src/3rdparty/xkbcommon/src/xkbcomp/include.c | 36 |
1 files changed, 28 insertions, 8 deletions
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); |