Fixed a bad pointer comparison in g_ascii_strtod that came up in fa_IR
authorRoozbeh Pournader <roozbeh@sharif.edu>
Wed, 26 Nov 2003 13:22:42 +0000 (13:22 +0000)
committerRoozbeh Pournader <roozbeh@src.gnome.org>
Wed, 26 Nov 2003 13:22:42 +0000 (13:22 +0000)
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.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gstrfuncs.c
tests/strtod-test.c

index c57480c177818497f7b758fff3b2690b77825fad..c5719123e3abe20ca916bc590059f21d2f72d193 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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.
+
 Sat Nov 22 14:16:51.15 2003  Andrew Lanoix  <alanoix@umich.edu>
 
        * glib/giowin32.c: Bind inter-thread comminication 
index c57480c177818497f7b758fff3b2690b77825fad..c5719123e3abe20ca916bc590059f21d2f72d193 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 Sat Nov 22 14:16:51.15 2003  Andrew Lanoix  <alanoix@umich.edu>
 
        * glib/giowin32.c: Bind inter-thread comminication 
index c57480c177818497f7b758fff3b2690b77825fad..c5719123e3abe20ca916bc590059f21d2f72d193 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 Sat Nov 22 14:16:51.15 2003  Andrew Lanoix  <alanoix@umich.edu>
 
        * glib/giowin32.c: Bind inter-thread comminication 
index c57480c177818497f7b758fff3b2690b77825fad..c5719123e3abe20ca916bc590059f21d2f72d193 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 Sat Nov 22 14:16:51.15 2003  Andrew Lanoix  <alanoix@umich.edu>
 
        * glib/giowin32.c: Bind inter-thread comminication 
index c57480c177818497f7b758fff3b2690b77825fad..c5719123e3abe20ca916bc590059f21d2f72d193 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 Sat Nov 22 14:16:51.15 2003  Andrew Lanoix  <alanoix@umich.edu>
 
        * glib/giowin32.c: Bind inter-thread comminication 
index c57480c177818497f7b758fff3b2690b77825fad..c5719123e3abe20ca916bc590059f21d2f72d193 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 Sat Nov 22 14:16:51.15 2003  Andrew Lanoix  <alanoix@umich.edu>
 
        * glib/giowin32.c: Bind inter-thread comminication 
index 31c655401f586b6cccc8925a7aa9aa3fd853f7bf..a4d6b1737cdec1ae26e78dd329d2ed007cd1539a 100644 (file)
@@ -433,7 +433,7 @@ g_ascii_strtod (const gchar *nptr,
 
       if (fail_pos)
        {
-         if (fail_pos > decimal_point_pos)
+         if (fail_pos - copy > decimal_point_pos - nptr)
            fail_pos = (char *)nptr + (fail_pos - copy) - (decimal_point_len - 1);
          else
            fail_pos = (char *)nptr + (fail_pos - copy);
index 180d926a9ddda54a8fde9b6fac49fa1ba7d2062b..df1755907ada1edeb1321e253ebb2f8fdfd7e62d 100644 (file)
@@ -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);
 }