Bug 883766 - JavaScript Warning: "reference to undefined property ret.value" {file: "resource://gre/modules/wifi_worker.js" line: 71} r=mrbkap
authorVincent Chang <vchang@mozilla.com>
Thu, 20 Jun 2013 18:43:15 +0800
changeset 151692 a965d9f77a3d470db8f85c8d9bb3d400ac8e54be
parent 151691 9a44247ea807ecb417d115a2e82d437ee550c599
child 151693 126c0732c9184a92c46b013dcd5739493220223a
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs883766
milestone25.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 883766 - JavaScript Warning: "reference to undefined property ret.value" {file: "resource://gre/modules/wifi_worker.js" line: 71} r=mrbkap
dom/wifi/wifi_worker.js
--- a/dom/wifi/wifi_worker.js
+++ b/dom/wifi/wifi_worker.js
@@ -63,18 +63,24 @@ self.onmessage = function(e) {
       }
 
       // Else if reply_len was 0, use the empty reply, set above.
     }
     postMessage({ id: id, status: ret, reply: reply });
     break;
   case "wait_for_event":
     var ret = libhardware_legacy.wait_for_event(cbuf, 4096);
-    var event = cbuf.readString().substr(0, ret.value);
-    postMessage({ id: id, event: event });
+    // Check the array index.
+    if (ret > 0 && ret < 4096) {
+      // Make sure the string buffer is null terminated.
+      cbuf[ret] = 0;
+      // Use readStringReplaceMalformed() to handle non-UTF8-encoded string.
+      var event = cbuf.readStringReplaceMalformed();
+      postMessage({ id: id, event: event });
+    }
     break;
   case "ifc_reset_connections":
     var ret = libnetutils.ifc_reset_connections(data.ifname,
                                                 libnetutils.RESET_ALL_ADDRESSES);
     postMessage({ id: id, status: ret });
     break;
   case "ifc_enable":
   case "ifc_disable":