# HG changeset patch
# User t_mrc-ct@users.sourceforge.jp
# Date 1372083202 -32400
# Branch GECKO17011esr_2013111808_RELBRANCH
# Node ID c22699681bb28da612c57024b6fca4349980d795
# Parent  6999b9d33dfd6ccf235d399f9504c117972a3bbc
fix bad endian swap

diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -1040,30 +1040,30 @@
          ((u & 0x0000ff00U) << 8) |
          ((u & 0x00ff0000U) >> 8) |
          ((u & 0xff000000U) >> 24);
 #else
   return u;
 #endif
 }
 
-static inline double
+static inline uint64_t
 SwapBytes(uint64_t u)
 {
 #ifdef IS_BIG_ENDIAN
   return ((u & 0x00000000000000ffLLU) << 56) |
          ((u & 0x000000000000ff00LLU) << 40) |
          ((u & 0x0000000000ff0000LLU) << 24) |
          ((u & 0x00000000ff000000LLU) << 8) |
          ((u & 0x000000ff00000000LLU) >> 8) |
          ((u & 0x0000ff0000000000LLU) >> 24) |
          ((u & 0x00ff000000000000LLU) >> 40) |
          ((u & 0xff00000000000000LLU) >> 56);
 #else
-  return double(u);
+  return u;
 #endif
 }
 
 static inline bool
 StructuredCloneReadString(JSStructuredCloneReader* aReader,
                           nsCString& aString)
 {
   uint32_t length;
@@ -2638,17 +2638,18 @@
       // which row id we would get above before we could set that properly.
 
       // This is a duplicate of the js engine's byte munging here
       union {
         double d;
         uint64_t u;
       } pun;
     
-      pun.d = SwapBytes(static_cast<uint64_t>(autoIncrementNum));
+      pun.d = static_cast<double>(static_cast<uint64_t>(autoIncrementNum));
+      pun.u = SwapBytes(pun.u);
 
       JSAutoStructuredCloneBuffer& buffer = mCloneWriteInfo.mCloneBuffer;
       uint64_t offsetToKeyProp = mCloneWriteInfo.mOffsetToKeyProp;
 
       memcpy((char*)buffer.data() + offsetToKeyProp, &pun.u, sizeof(uint64_t));
     }
   }
 
