mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
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:
parent
0b8793ab0c
commit
6cf5e8f932
1 changed files with 5 additions and 2 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue