Bug 821158 - Extract a number out of the size_t-containing object. r=jst
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 12 Dec 2012 19:18:50 -0800
changeset 115889 72913ea85419123674f4fa2d04890b0163998698
parent 115888 caf2b8ec76f9683b219ff785e7f58a779351b16c
child 115890 9ff7b0790b02501f39f968477d6693c54f4569d6
push id24028
push useremorley@mozilla.com
push dateThu, 13 Dec 2012 15:56:02 +0000
treeherdermozilla-central@9db79b97abbb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs821158
milestone20.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 821158 - Extract a number out of the size_t-containing object. r=jst
dom/wifi/wifi_worker.js
--- a/dom/wifi/wifi_worker.js
+++ b/dom/wifi/wifi_worker.js
@@ -45,17 +45,19 @@ self.onmessage = function(e) {
     var ret = libhardware_legacy.command(data.request, cbuf, len.address());
     var reply = "";
     if (!ret) {
       // The return value from libhardware_legacy.command is not guaranteed to
       // be null-terminated. At the same time we want to make sure that we
       // don't return a response with a trailing newline, so handle both cases
       // here. Note that if we wrote 4096 characters to cbuf, we don't have to
       // null-terminate the buffer, as ctypes has the maximum size already.
-      var reply_len = len.value;
+      // Note also that len.value is an object. We can ignore the high 32 bits
+      // because we know that the maximum that it can be is 4096.
+      var reply_len = ctypes.UInt64.lo(len.value);
       if (reply_len !== 0) {
         if (cbuf[reply_len - 1] === 10)
           cbuf[--reply_len] = 0;
         else if (reply_len !== 4096)
           cbuf[reply_len] = 0;
 
         reply = cbuf.readString();
       }