mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
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.
This commit is contained in:
committed by
Roozbeh Pournader
parent
94d79f087b
commit
6e3b71aec3
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user