mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-31 12:53:07 +02:00
gtestutils: Add an assertion to squash a scan-build false positive
scan-build thinks there’s a potential `NULL` pointer dereference of some of the members of `msg->strings`, because it doesn’t know about the implicit invariant that the length of `msg->strings` is `msg->n_strings`. Ideally we want an assertion like `g_assert (g_strv_length (msg->strings) == msg->n_strings)`, but that’s not very performant, so just settle for a non-`NULL` assertion on each loop iteration to give scan-build the hint it needs. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #1767
This commit is contained in:
parent
cf940496df
commit
2d5fc78f63
@ -4308,7 +4308,9 @@ g_test_log_dump (GTestLogMsg *msg,
|
|||||||
gstring_append_int (gstring, 0); /* reserved */
|
gstring_append_int (gstring, 0); /* reserved */
|
||||||
for (ui = 0; ui < msg->n_strings; ui++)
|
for (ui = 0; ui < msg->n_strings; ui++)
|
||||||
{
|
{
|
||||||
guint l = strlen (msg->strings[ui]);
|
guint l;
|
||||||
|
g_assert (msg->strings[ui] != NULL);
|
||||||
|
l = strlen (msg->strings[ui]);
|
||||||
gstring_append_int (gstring, l);
|
gstring_append_int (gstring, l);
|
||||||
g_string_append_len (gstring, msg->strings[ui], l);
|
g_string_append_len (gstring, msg->strings[ui], l);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user