diff options
| author | Simon Ser <contact@emersion.fr> | 2022-05-27 16:54:49 +0200 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2022-05-27 22:41:11 +0200 |
| commit | 6cf5e8f9324095f2226ee666eee9090fbc6da287 (patch) | |
| tree | 532caeacf2c2d01fda6e2e544bba34389badd1c1 /cursor/xcursor.c | |
| parent | cursor: remove unnecessary parentheses in load_all_cursors_from_dir (diff) | |
| download | wayland-6cf5e8f9324095f2226ee666eee9090fbc6da287.tar wayland-6cf5e8f9324095f2226ee666eee9090fbc6da287.tar.gz wayland-6cf5e8f9324095f2226ee666eee9090fbc6da287.tar.bz2 wayland-6cf5e8f9324095f2226ee666eee9090fbc6da287.tar.lz wayland-6cf5e8f9324095f2226ee666eee9090fbc6da287.tar.xz wayland-6cf5e8f9324095f2226ee666eee9090fbc6da287.tar.zst wayland-6cf5e8f9324095f2226ee666eee9090fbc6da287.zip | |
cursor: use getline instead of fgets
This avoids storing 8KiB on the stack, and removes the line length
limit.
Signed-off-by: Simon Ser <contact@emersion.fr>
Diffstat (limited to 'cursor/xcursor.c')
| -rw-r--r-- | cursor/xcursor.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cursor/xcursor.c b/cursor/xcursor.c index 1974802..315fe00 100644 --- a/cursor/xcursor.c +++ b/cursor/xcursor.c @@ -698,7 +698,8 @@ xcursor_sep(char c) static char * xcursor_theme_inherits(const char *full) { - char line[8192]; + char *line = NULL; + size_t line_size = 0; char *result = NULL; FILE *f; @@ -709,7 +710,7 @@ xcursor_theme_inherits(const char *full) if (!f) return NULL; - while (fgets(line, sizeof(line), f)) { + while (getline(&line, &line_size, f) >= 0) { if (strncmp(line, "Inherits", 8)) continue; @@ -743,6 +744,8 @@ xcursor_theme_inherits(const char *full) } fclose(f); + free(line); + return result; } |
