Bug 1321562 - Fix bugs in GeckoBundle.fromJSONObject; r=me
authorJim Chen <nchen@mozilla.com>
Thu, 01 Dec 2016 12:25:22 -0500
changeset 325000 083ffc01652a13e80d12288074fd5dbc39621e93
parent 324999 47e2650093d575c5042b43feb0575ef9678352b1
child 325001 b49684127ce464141b0a989cd621cb4794b6a85f
child 325032 8083de7bddbc48c2cdf35c4810746b4e6ea9d13f
push id31023
push userkwierso@gmail.com
push dateThu, 01 Dec 2016 23:32:03 +0000
treeherdermozilla-central@b49684127ce4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1321562
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1321562 - Fix bugs in GeckoBundle.fromJSONObject; r=me Fix a crash in GeckoBundle.fromJSONObject due to wrong values array type. Also, fix a bug where the first element of a converted array is repeated. r=me for trivial patch.
mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/GeckoBundle.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/GeckoBundle.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/GeckoBundle.java
@@ -631,17 +631,17 @@ public final class GeckoBundle {
         if (value instanceof JSONArray) {
             final JSONArray array = (JSONArray) value;
             final int len = array.length();
             if (len == 0) {
                 return EMPTY_BOOLEAN_ARRAY;
             }
             Object out = null;
             for (int i = 0; i < len; i++) {
-                final Object element = fromJSONValue(array.opt(0));
+                final Object element = fromJSONValue(array.opt(i));
                 if (element == null) {
                     continue;
                 }
                 if (out == null) {
                     Class<?> type = element.getClass();
                     if (type == Boolean.class) {
                         type = boolean.class;
                     } else if (type == Integer.class) {
@@ -672,17 +672,17 @@ public final class GeckoBundle {
     }
 
     public static GeckoBundle fromJSONObject(final JSONObject obj) throws JSONException {
         if (obj == null || obj == JSONObject.NULL) {
             return null;
         }
 
         final String[] keys = new String[obj.length()];
-        final Object[] values = new String[obj.length()];
+        final Object[] values = new Object[obj.length()];
 
         final Iterator<String> iter = obj.keys();
         for (int i = 0; iter.hasNext(); i++) {
             final String key = iter.next();
             keys[i] = key;
             values[i] = fromJSONValue(obj.opt(key));
         }
         return new GeckoBundle(keys, values);