diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp index 8d7137a4..53ccef8e 100644 --- a/src/gb/GB.cpp +++ b/src/gb/GB.cpp @@ -2437,7 +2437,7 @@ void gbReset() gbTimerOn = false; if(gbCgbMode) { - for (int i = 0; i<0x20; i++) + for (i = 0; i<0x20; i++) gbPalette[i] = 0x7fff; // This is just to show that the starting values of the OBJ palettes are different @@ -2555,11 +2555,11 @@ void gbReset() } } else { if(gbSgbMode) { - for(int i = 0; i < 8; i++) + for(i = 0; i < 8; i++) gbPalette[i] = systemGbPalette[gbPaletteOption*8+i]; } - for(int i = 0; i < 8; i++) + for(i = 0; i < 8; i++) gbPalette[i] = systemGbPalette[gbPaletteOption*8+i]; } @@ -4079,7 +4079,9 @@ bool gbUpdateSizes() } if(gbRomSize < gbRomSizes[gbRom[0x148]]) { - gbRom = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]); + u8 *gbRomNew = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]); + if( !gbRomNew ) { assert( false ); return false; }; + gbRom = gbRomNew; for (int i = gbRomSize; i> 12) + 3; int offset = (data & 0x0FFF); u32 windowOffset = dest + byteCount - offset - 1; - for(int i = 0; i < length; i++) { + for(int i2 = 0; i2 < length; i2++) { writeValue |= (CPUReadByte(windowOffset++) << byteShift); byteShift += 8; byteCount++; @@ -781,7 +781,7 @@ void BIOS_LZ77UnCompWram() int length = (data >> 12) + 3; int offset = (data & 0x0FFF); u32 windowOffset = dest - offset - 1; - for(int i = 0; i < length; i++) { + for(int i2 = 0; i2 < length; i2++) { CPUWriteByte(dest++, CPUReadByte(windowOffset++)); len--; if(len == 0) diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp index 010bb87f..e9f9cda9 100644 --- a/src/win32/VBA.cpp +++ b/src/win32/VBA.cpp @@ -968,7 +968,7 @@ void systemDrawScreen() theApp.aviRecorder = NULL; theApp.aviRecording = false; } - delete bmp; + delete [] bmp; } } @@ -2141,7 +2141,7 @@ void VBA::updatePriority() bool VBA::detectMMX() { bool support = false; - char brand[13]; + char brand[12]; // not zero terminated // check for Intel chip __try { diff --git a/src/win32/XAudio2.cpp b/src/win32/XAudio2.cpp index 2a4013bc..73de71c5 100644 --- a/src/win32/XAudio2.cpp +++ b/src/win32/XAudio2.cpp @@ -211,6 +211,7 @@ bool XAudio2_Output::init(long sampleRate) ASSERT( hr == S_OK ); float *matrix = NULL; matrix = (float*)malloc( sizeof( float ) * 2 * dd.OutputFormat.Format.nChannels ); + if( matrix == NULL ) return false; bool matrixAvailable = true; switch( dd.OutputFormat.Format.nChannels ) { case 4: // 4.0