diff options
author | Roozbeh Pournader <roozbeh@sharif.edu> | 2003-11-26 13:22:42 +0000 |
---|---|---|
committer | Roozbeh Pournader <roozbeh@src.gnome.org> | 2003-11-26 13:22:42 +0000 |
commit | 6e3b71aec363e41035bbe7f7bda30a14a40c9662 (patch) | |
tree | 633a6ea80ab8a896f9fba8f6925509782d351b70 /tests | |
parent | 94d79f087ba4470dba5e9c9924f73b01499a0e88 (diff) |
Fixed a bad pointer comparison in g_ascii_strtod that came up in fa_IR
Wed Nov 26 16:45:16 2003 Roozbeh Pournader <roozbeh@sharif.edu>
* glib/gstrfuncs.c: Fixed a bad pointer comparison in
g_ascii_strtod that came up in fa_IR locale (#126640, Behdad
Esfahbod).
* tests/strtod-test.c: Fixed the tests to catch the above.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/strtod-test.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/strtod-test.c b/tests/strtod-test.c index 180d926a9..df1755907 100644 --- a/tests/strtod-test.c +++ b/tests/strtod-test.c @@ -13,6 +13,14 @@ test_string (char *number, double res) char *locales[] = {"sv_SE", "en_US", "fa_IR", "C"}; int l; char *end; + char *dummy; + + /* we try a copy of number, with some free space for malloc before that. + * This is supposed to smash the some wrong pointer calculations. */ + + dummy = g_malloc (100000); + number = g_strdup (number); + g_free (dummy); for (l = 0; l < G_N_ELEMENTS (locales); l++) { @@ -20,9 +28,11 @@ test_string (char *number, double res) d = g_ascii_strtod (number, &end); if (d != res) g_print ("g_ascii_strtod for locale %s failed\n", locales[l]); - if (*end != 0) + if (end - number != strlen(number)) g_print ("g_ascii_strtod for locale %s endptr was wrong\n", locales[l]); } + + g_free (number); } |