diff options
author | Tobias Stoeckmann <tobias@stoeckmann.org> | 2021-05-04 18:30:53 +0200 |
---|---|---|
committer | Tobias Stoeckmann <tobias@stoeckmann.org> | 2021-05-04 18:59:46 +0200 |
commit | 6edf1caf6fe6826b3727ab19ba9e4d7ad163a48e (patch) | |
tree | 864822758a685b588a68378232c4e591adcb17f5 | |
parent | b47ca9858ee11bdbd08f1e31102116ff51cb6be5 (diff) |
fix XcursorTheme loop regression
Handle themes with multiple inherit entries. Although the previous
commit keeped track of inherited themes, it only handled multiple theme
entries on the highest level.
This fix unconditionally checks if the next upper level contains a line.
If it does, it processes contained themes (i.e. the current theme had an
inherited entry in its index file).
If the upper level has no more themes, it goes down a level and
processes the next theme there. If no next theme exists, it moves down
another level and so on until it reaches level 0, i.e. the initially
supplied theme.
The lowest level (d = 0) is treated specially because we must not modify
the supplied theme, which could happen when calling _XcursorNextPath.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
-rw-r--r-- | src/library.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/library.c b/src/library.c index 238f8ac..83527c4 100644 --- a/src/library.c +++ b/src/library.c @@ -263,7 +263,7 @@ XcursorScanTheme (const char *theme, const char *name) if (d + 1 >= MAX_INHERITS_DEPTH) { free (dir); - goto cleanup; + goto finish; } full = _XcursorBuildFullname (dir, "", "index.theme"); if (full) @@ -277,22 +277,17 @@ XcursorScanTheme (const char *theme, const char *name) } } - if (inherits[d + 1].line == NULL) + d++; + while (d > 0 && inherits[d].theme == NULL) { - if (d == 0) + free (inherits[d].line); + inherits[d].line = NULL; + + if (--d == 0) inherits[d].theme = NULL; else - { inherits[d].theme = _XcursorNextPath (inherits[d].theme); - if (inherits[d].theme == NULL) - { - free (inherits[d].line); - inherits[d--].line = NULL; - } - } } - else - d++; /* * Detect and break self reference loop early on. @@ -301,7 +296,7 @@ XcursorScanTheme (const char *theme, const char *name) break; } -cleanup: +finish: for (d = 1; d <= MAX_INHERITS_DEPTH; d++) free (inherits[d].line); |