After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 742639 - region: fix a crash when iterating locales
region: fix a crash when iterating locales
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Region & Language
unspecified
Other All
: Normal normal
: ---
Assigned To: Control-Center Maintainers
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-01-09 11:16 UTC by Cosimo Cecchi
Modified: 2015-01-10 03:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
region: fix a crash when iterating locales (1.71 KB, patch)
2015-01-09 11:16 UTC, Cosimo Cecchi
committed Details | Review

Description Cosimo Cecchi 2015-01-09 11:16:44 UTC
See patch
Comment 1 Cosimo Cecchi 2015-01-09 11:16:48 UTC
Created attachment 294150 [details] [review]
region: fix a crash when iterating locales

When iterating locales in the format chooser,
gnome_get_country_from_locale() is called for each of them to build the
locale label for the list row.

The function creating the label doesn't take into account that
gnome_get_country_from_locale() can return NULL, in which case it will
both:
- display an empty row in the list
- crash when later trying to find a word in a NULL string with strstr()
  inside match_all()

Just avoid creating a widget in that case.
Comment 2 Bastien Nocera 2015-01-09 12:05:56 UTC
Review of attachment 294150 [details] [review]:

What caused gnome_get_country_from_locale() to return NULL?

I'll let Rui review the patch.
Comment 3 Cosimo Cecchi 2015-01-09 12:35:46 UTC
It can return NULL when gnome_parse_locale() returns NULL on one of its out arguments; I haven't investigated exactly why that is the case on the system I saw this crash, but perhaps there's one locale installed on the system with incomplete information.
In any case, since the API can return NULL it doesn't seem a bad idea to be robust to it...
Comment 4 Rui Matos 2015-01-09 17:35:06 UTC
Review of attachment 294150 [details] [review]:

looks good, thanks
Comment 5 Rui Matos 2015-01-09 17:38:56 UTC
(In reply to comment #3)
> It can return NULL when gnome_parse_locale() returns NULL on one of its out
> arguments; I haven't investigated exactly why that is the case on the system I
> saw this crash, but perhaps there's one locale installed on the system with
> incomplete information.
> In any case, since the API can return NULL it doesn't seem a bad idea to be
> robust to it...

Yes that's true. There's no way around it since the locale string can just be incomplete or even totally bogus and thus it can't determine the country.
Comment 6 Cosimo Cecchi 2015-01-10 03:45:16 UTC
Thanks, pushed to master.

Attachment 294150 [details] pushed as eb93004 - region: fix a crash when iterating locales