diff options
author | Adam Paszke <adam.paszke@gmail.com> | 2016-04-18 19:50:11 +0300 |
---|---|---|
committer | Adam Paszke <adam.paszke@gmail.com> | 2016-04-18 19:50:11 +0300 |
commit | a8c8b8dc1f1845f24632431ccc197f166a916115 (patch) | |
tree | 8e6db78ad4208203a221206122fbe7f09a1ba589 | |
parent | 1a1731f3f4bed1027740a216f90685c1b181f7e6 (diff) |
Fix pointer overflows in sharedserialize
-rw-r--r-- | sharedserialize.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sharedserialize.lua b/sharedserialize.lua index 6e09a90..9cd8ebf 100644 --- a/sharedserialize.lua +++ b/sharedserialize.lua @@ -27,13 +27,22 @@ if tds then -- vec local mt = {} function mt.__factory(f) - local self = f:readLong() + local self + if ffi.sizeof('long') == 4 then + self = f:readDouble() + else + self = f:readLong() + end self = ffi.cast('tds_vec&', self) ffi.gc(self, tds.C.tds_vec_free) return self end function mt.__write(self, f) - f:writeLong(torch.pointer(self)) + if ffi.sizeof('long') == 4 then + f:writeDouble(torch.pointer(self)) + else + f:writeLong(torch.pointer(self)) + end tds.C.tds_vec_retain(self) end function mt.__read(self, f) |