Pinpointed by gcc 13 warning:
warning: dereference of possibly-NULL āpā [CWE-690] [-Wanalyzer-possible-null-dereference]
* libtextstyle/gnulib-local/lib/term-ostream.oo.c (term_ostream_create): If
xgethostname() returns NULL, use a dummy hash code.
char *hostname = xgethostname ();
{ /* Compute a hash code, like in gnulib/lib/hash-pjw.c. */
uint32_t h = 0;
- const char *p;
- for (p = hostname; *p; p++)
- h = (unsigned char) *p + ((h << 9) | (h >> (32 - 9)));
+ if (hostname != NULL)
+ {
+ const char *p;
+ for (p = hostname; *p; p++)
+ h = (unsigned char) *p + ((h << 9) | (h >> (32 - 9)));
+ }
stream->hostname_hash = h;
}
free (hostname);