mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
cursor: check return value of snprintf()
Fixes a new warning in GCC 7:
FAILED: cursor/libwayland-cursor.so.0.22.90.p/xcursor.c.o
cc -Icursor/libwayland-cursor.so.0.22.90.p -Icursor -I../cursor -I. -I.. -Isrc -I../src -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c99 -O3 -D_POSIX_C_SOURCE=200809L -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -fvisibility=hidden -fPIC '-DICONDIR="/usr/share/X11/icons"' -MD -MQ cursor/libwayland-cursor.so.0.22.90.p/xcursor.c.o -MF cursor/libwayland-cursor.so.0.22.90.p/xcursor.c.o.d -o cursor/libwayland-cursor.so.0.22.90.p/xcursor.c.o -c ../cursor/xcursor.c
../cursor/xcursor.c: In function 'xcursor_load_theme':
../cursor/xcursor.c:596:39: error: '%s' directive output between 7 and 7 bytes may cause result to exceed 'INT_MAX' [-Werror=format-truncation=]
596 | snprintf(full, full_size, "%s/%s/%s", dir, subdir, file);
| ^~
......
764 | full = xcursor_build_fullname(dir, "cursors", "");
| ~~~~~~~~~
../cursor/xcursor.c:596:41: error: '/' directive output between 1 and 1 bytes may cause result to exceed 'INT_MAX' [-Werror=format-truncation=]
596 | snprintf(full, full_size, "%s/%s/%s", dir, subdir, file);
| ^
cc1: all warnings being treated as errors
Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
72da004b3e
commit
7b27881cd1
1 changed files with 6 additions and 1 deletions
|
|
@ -585,6 +585,7 @@ xcursor_build_fullname(const char *dir, const char *subdir, const char *file)
|
|||
{
|
||||
char *full;
|
||||
size_t full_size;
|
||||
int ret;
|
||||
|
||||
if (!dir || !subdir || !file)
|
||||
return NULL;
|
||||
|
|
@ -593,7 +594,11 @@ xcursor_build_fullname(const char *dir, const char *subdir, const char *file)
|
|||
full = malloc(full_size);
|
||||
if (!full)
|
||||
return NULL;
|
||||
snprintf(full, full_size, "%s/%s/%s", dir, subdir, file);
|
||||
ret = snprintf(full, full_size, "%s/%s/%s", dir, subdir, file);
|
||||
if (ret < 0) {
|
||||
free(full);
|
||||
return NULL;
|
||||
}
|
||||
return full;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue