Skip to content

gnome-languages: Avoid passing NULL to newlocale

Passing NULL to newlocale is not warrantied to return an error, but only "may" according to POSIX.1-2008[1]. For this function glibc returns an error instead of treating the NULL pointer as undefined behaviour. However, that is not the case in muslc, which generates a segmentation fault.

This commit makes sure that any call to newlocale is preceded by a NULL pointer check. It makes the code more conformant to POSIX.1-2008 and gives an intepretation of what a NULL locale means in this piece of code.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/newlocale.html

Merge request reports