Revision: 7205
Author: [email protected]
Date: Mon Nov 30 14:41:59 2009
Log: Fix float/double crash on Firefox with max values.

1) Fix debug printing code from %f (which can overflow a buffer) to %g  
(which won't).
2) Compile out more debugging code anyway to avoid calling Value.toString()  
at all.

Review by: jat (desk)
http://code.google.com/p/google-web-toolkit/source/detail?r=7205

Modified:
  /trunk/plugins/common/Value.h
  /trunk/user/test/com/google/gwt/dev/jjs/test/HostedTest.java

=======================================
--- /trunk/plugins/common/Value.h       Mon Aug  3 08:30:11 2009
+++ /trunk/plugins/common/Value.h       Mon Nov 30 14:41:59 2009
@@ -301,7 +301,7 @@
    }

    std::string toString() const {
-    char buf[30];
+    char buf[64];
      switch (type) {
        case NULL_TYPE:
          return "null";
@@ -326,10 +326,10 @@
              static_cast<long long>(getLong()));
          return std::string(buf);
        case FLOAT:
-        snprintf(buf, sizeof(buf), "float(%f)", getFloat());
+        snprintf(buf, sizeof(buf), "float(%g)", getFloat());
          return std::string(buf);
        case DOUBLE:
-        snprintf(buf, sizeof(buf), "double(%lf)", getDouble());
+        snprintf(buf, sizeof(buf), "double(%g)", getDouble());
          return std::string(buf);
        case STRING:
          snprintf(buf, sizeof(buf), "string(%.20s)", getString().c_str());
@@ -381,7 +381,10 @@
  };

  inline Debug::DebugStream& operator<<(Debug::DebugStream& dbg, const  
Value& val) {
-  return dbg << val.toString();
+  if (dbg.isActive()) {
+    dbg << val.toString();
+  }
+  return dbg;
  }

  #endif
=======================================
--- /trunk/user/test/com/google/gwt/dev/jjs/test/HostedTest.java        Fri Oct 
16  
12:07:20 2009
+++ /trunk/user/test/com/google/gwt/dev/jjs/test/HostedTest.java        Mon Nov 
30  
14:41:59 2009
@@ -276,12 +276,7 @@
      assertEquals("VAL3-foo", TestEnum.VAL3.foo());
    }

-  /**
-   * Returning Float.MAX_VALUE or Double.MAX_VALUE causes firefox to crash  
on
-   * Windows in dev mode
-   * TODO (jat): Enable this test before shipping GWT 2.0.
-   */
-  public void disabledTestFloat() {
+  public void testFloat() {
      storeFloat(Float.MIN_VALUE);
      float f = getFloat();
      assertTrue(f == Float.MIN_VALUE);
@@ -415,12 +410,8 @@
    /**
     * More test cases resulting from issue 2426 to show that primitives can  
be
     * passed through JSNI methods unmolested.
-   *
-   * Returning Float.MAX_VALUE or Double.MAX_VALUE causes firefox to crash  
on
-   * Windows in dev mode
-   * TODO(jat): Enable this test before shipping GWT 2.0.
     */
-  public void disabledTestJsniPassthroughPrimitives() {
+  public void testJsniPassthroughPrimitives() {
      class Inner {
        native boolean nativeBoolean(boolean param) /*-{
          return param;

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to