gdir: Add trailing nul delimiter to FILENAME_MAX

`FILENAME_MAX` is not guaranteed to include a trailing nul delimiter, so
explicitly add one.

See
https://www.gnu.org/software/libc/manual/html_node/Limits-for-Files.html:
`PATH_MAX` is explicitly defined to include a nul delimiter;
`FILENAME_MAX` is not.

See also https://twitter.com/pid_eins/status/1357008940886818822.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2021-04-19 19:24:08 +01:00
parent 496135c569
commit 3131a6149e

View File

@ -60,7 +60,9 @@ struct _GDir
DIR *dirp;
#endif
#ifdef G_OS_WIN32
gchar utf8_buf[FILENAME_MAX*4];
/* maximum encoding of FILENAME_MAX UTF-8 characters, plus a nul terminator
* (FILENAME_MAX is not guaranteed to include one) */
gchar utf8_buf[FILENAME_MAX*4 + 1];
#endif
};