gstring: Avoid warnings from inline functions

The current code for g_string_append_c_inline generates
warnings when used, with -Wnull-dereference. Avoid that.
This commit is contained in:
Matthias Clasen 2023-02-02 08:59:36 +01:00 committed by Philip Withnall
parent 964ecf5ec9
commit d9f8d73be2

View File

@ -187,7 +187,8 @@ static inline GString*
g_string_append_c_inline (GString *gstring,
gchar c)
{
if (G_LIKELY (gstring->len + 1 < gstring->allocated_len))
if (G_LIKELY (gstring != NULL &&
gstring->len + 1 < gstring->allocated_len))
{
gstring->str[gstring->len++] = c;
gstring->str[gstring->len] = 0;