pcsx2|lilypad: Unintentional integer overflow

Add some cast to do the intermediate operation in 64 bits
This commit is contained in:
Gregory Hainaut 2015-09-11 16:50:02 +02:00
parent 6c7ce3465e
commit bfe1236d98
3 changed files with 3 additions and 3 deletions

View File

@ -244,7 +244,7 @@ int CsoFileReader::ReadFromFrame(u8 *dest, u64 pos, int maxBytes) {
// Calculate where the compressed payload is (if compressed.)
const u64 frameRawPos = (u64)index0 << m_indexShift;
const u64 frameRawSize = (index1 - index0) << m_indexShift;
const u64 frameRawSize = (u64)(index1 - index0) << m_indexShift;
if (!compressed) {
// Just read directly, easy.

View File

@ -63,7 +63,7 @@ static Access* ReadIndexFromFile(const wxString& filename) {
infile.read((char*)index, sizeof(Access));
s64 datasize = size - GZIP_ID_LEN - sizeof(Access);
if (datasize != index->have * sizeof(Point)) {
if (datasize != (s64)index->have * sizeof(Point)) {
Console.Error(L"Error: unexpected size of gzip index, please delete it manually: '%s'.", WX_STR(filename));
infile.close();
free(index);

View File

@ -74,7 +74,7 @@ static inline int wcsicmp(const wchar_t* w1, const wchar_t* w2) {
static inline unsigned int timeGetTime() {
struct timeval now;
gettimeofday(&now, NULL);
uint64_t ms = (now.tv_usec/1000) + (now.tv_sec * 1000);
uint64_t ms = (now.tv_usec/1000) + ((uint64_t)now.tv_sec * 1000);
return (ms & 0xFFFFFFFF); // MS code is u32 ...
}