mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-28 23:16:14 +01:00
gfileutils: Add an assertion to help static analysis
This assertion basically mirrors the existing `buffer_size >= 2` assertion (one implies the other), but scan-build doesn’t seem to be able to work that out — so give it some help. Fixes: ``` ../../../glib/gfileutils.c: In function ‘g_get_current_dir’: ../../../glib/gfileutils.c:2995:17: warning: potential null pointer dereference [-Wnull-dereference] 2995 | buffer[1] = 0; | ~~~~~~~~~~^~~ ../../../glib/gfileutils.c:2994:17: warning: potential null pointer dereference [-Wnull-dereference] 2994 | buffer[0] = G_DIR_SEPARATOR; ``` Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
parent
68388cf7f7
commit
1ab1cd6ba4
@ -2991,6 +2991,7 @@ g_get_current_dir (void)
|
||||
{
|
||||
/* Fallback return value */
|
||||
g_assert (buffer_size >= 2);
|
||||
g_assert (buffer != NULL);
|
||||
buffer[0] = G_DIR_SEPARATOR;
|
||||
buffer[1] = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user