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 111155 dd69215593f6e345f0ea0f842204d235161759fd
parent 111154 4f3a1bcdc429425a6edbd1f680ce6fa17ff67c4e
child 111156 2612d7f2b20d75cfeb39f8b39e356b7126dbcec7
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersbenjamin
bugs803707
milestone19.0a1
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));