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>
This commit is contained in:
Simon Ser 2022-05-27 16:54:49 +02:00
parent 0b8793ab0c
commit 6cf5e8f932

View file

@ -698,7 +698,8 @@ xcursor_sep(char c)
static char * static char *
xcursor_theme_inherits(const char *full) xcursor_theme_inherits(const char *full)
{ {
char line[8192]; char *line = NULL;
size_t line_size = 0;
char *result = NULL; char *result = NULL;
FILE *f; FILE *f;
@ -709,7 +710,7 @@ xcursor_theme_inherits(const char *full)
if (!f) if (!f)
return NULL; return NULL;
while (fgets(line, sizeof(line), f)) { while (getline(&line, &line_size, f) >= 0) {
if (strncmp(line, "Inherits", 8)) if (strncmp(line, "Inherits", 8))
continue; continue;
@ -743,6 +744,8 @@ xcursor_theme_inherits(const char *full)
} }
fclose(f); fclose(f);
free(line);
return result; return result;
} }