Bug 803707 - Don't assume pointers are 64 bits. r=benjamin.
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Mon, 22 Oct 2012 09:07:04 -0400
changeset 110932 dd69215593f6e345f0ea0f842204d235161759fd
parent 110931 4f3a1bcdc429425a6edbd1f680ce6fa17ff67c4e
child 110933 2612d7f2b20d75cfeb39f8b39e356b7126dbcec7
push id16822
push userrespindola@mozilla.com
push dateMon, 22 Oct 2012 13:07:09 +0000
treeherdermozilla-inbound@dd69215593f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenjamin
bugs803707
milestone19.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 803707 - Don't assume pointers are 64 bits. r=benjamin.
js/src/jsclone.cpp
--- a/js/src/jsclone.cpp
+++ b/js/src/jsclone.cpp
@@ -326,17 +326,22 @@ SCInput::readChars(jschar *p, size_t nch
 {
     JS_ASSERT(sizeof(jschar) == sizeof(uint16_t));
     return readArray((uint16_t *) p, nchars);
 }
 
 bool
 SCInput::readPtr(void **p)
 {
-    return read((uint64_t *)p);
+    // On a 32 bit system the void* variable we have to write to is only
+    // 32 bits, so we create a 64 temporary and discard the unused bits.
+    uint64_t tmp;
+    bool ret = read(&tmp);
+    *p = (void *) tmp;
+    return ret;
 }
 
 SCOutput::SCOutput(JSContext *cx) : cx(cx), buf(cx) {}
 
 bool
 SCOutput::write(uint64_t u)
 {
     return buf.append(SwapBytes(u));