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 768504 - keyfile: g_key_file_get_double behavior doesn't follow documentation
keyfile: g_key_file_get_double behavior doesn't follow documentation
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gkeyfile
2.49.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-07-07 08:32 UTC by Aurélien Zanelli
Modified: 2016-07-17 00:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[1/2] glib/tests/keyfile: check return value of g_key_file_get_double is 0 for invalid values (1.97 KB, patch)
2016-07-07 08:34 UTC, Aurélien Zanelli
committed Details | Review
[2/2] keyfile: return 0 when the parsed double value is invalid (776 bytes, patch)
2016-07-07 08:35 UTC, Aurélien Zanelli
committed Details | Review

Description Aurélien Zanelli 2016-07-07 08:32:28 UTC
Documentation of g_key_file_get_double said that it returns 0.0 when the value can't be interpreted as a double and the error is set to G_KEY_FILE_ERROR_INVALID_VALUE.
However, when the value can be partially parsed, for instance '1.0.0' or '1.0foo', the returned double value is not 0.0 but 1.0.
Comment 1 Aurélien Zanelli 2016-07-07 08:34:13 UTC
Created attachment 330983 [details] [review]
[1/2] glib/tests/keyfile: check return value of g_key_file_get_double is 0 for invalid values

Update keyfile test to chech returned values of g_key_file_get_double for invalid keys.
Comment 2 Aurélien Zanelli 2016-07-07 08:35:33 UTC
Created attachment 330985 [details] [review]
[2/2] keyfile: return 0 when the parsed double value is invalid

Set return value to 0 when we set the INVALID_VALUE error.
Comment 3 Matthias Clasen 2016-07-13 02:31:31 UTC
Review of attachment 330983 [details] [review]:

Looks correct
Comment 4 Matthias Clasen 2016-07-13 02:31:50 UTC
Review of attachment 330985 [details] [review]:

yes