summaryrefslogtreecommitdiff
path: root/Source/Plugins
diff options
context:
space:
mode:
authordrkiiraziel <drkiiraziel@gmail.com>2008-11-15 02:30:29 +0000
committerdrkiiraziel <drkiiraziel@gmail.com>2008-11-15 02:30:29 +0000
commit9a4dc4e8102d10feef3d324ace7a3198013c5bd6 (patch)
treee31cc8110aeb8ae0c5e0ad1cc2182482c51eb1d3 /Source/Plugins
parentab1774b28a6a7cbdf52e9114ef323bee067e387c (diff)
Fixed small buffer overruns and other minor bugs that were found by VS2008 code analysis
Added a check on both video plugins to prevent crashing when Memory_GetPtr retuns null pointer at ExecuteDisplayList (invalid address? Dave Mirra BMX 2 crashes there ...) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1179 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Plugins')
-rw-r--r--Source/Plugins/Plugin_VideoDX9/Src/OpcodeDecoding.cpp31
-rw-r--r--Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp2
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp2
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.h4
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/OpcodeDecoding.cpp29
5 files changed, 39 insertions, 29 deletions
diff --git a/Source/Plugins/Plugin_VideoDX9/Src/OpcodeDecoding.cpp b/Source/Plugins/Plugin_VideoDX9/Src/OpcodeDecoding.cpp
index fcf8346d36..fa1fc7d943 100644
--- a/Source/Plugins/Plugin_VideoDX9/Src/OpcodeDecoding.cpp
+++ b/Source/Plugins/Plugin_VideoDX9/Src/OpcodeDecoding.cpp
@@ -54,23 +54,28 @@ static void ExecuteDisplayList(u32 address, u32 size)
u8* old_pVideoData = g_pVideoData;
u8* startAddress = Memory_GetPtr(address);
- g_pVideoData = startAddress;
- // temporarily swap dl and non-dl(small "hack" for the stats)
- Statistics::SwapDL();
+ //Avoid the crash if Memory_GetPtr failed ..
+ if (startAddress!=0)
+ {
+ g_pVideoData = startAddress;
- while((u32)(g_pVideoData - startAddress) < size)
- {
- Decode();
- }
- INCSTAT(stats.numDListsCalled);
- INCSTAT(stats.thisFrame.numDListsCalled);
+ // temporarily swap dl and non-dl(small "hack" for the stats)
+ Statistics::SwapDL();
- // un-swap
- Statistics::SwapDL();
+ while((u32)(g_pVideoData - startAddress) < size)
+ {
+ Decode();
+ }
+ INCSTAT(stats.numDListsCalled);
+ INCSTAT(stats.thisFrame.numDListsCalled);
- // reset to the old pointer
- g_pVideoData = old_pVideoData;
+ // un-swap
+ Statistics::SwapDL();
+
+ // reset to the old pointer
+ g_pVideoData = old_pVideoData;
+ }
}
bool FifoCommandRunnable()
diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp
index 4cd62306bb..a627df974d 100644
--- a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp
+++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp
@@ -200,7 +200,7 @@ void TextureCache::Load(int stage, u32 address, int width, int height, int forma
{ // dump texture to file
static int counter = 0;
char szTemp[MAX_PATH];
- sprintf(szTemp, "%s\\txt_%04i_%i.png", g_Config.texDumpPath, counter++, format);
+ sprintf(szTemp, "%s\\txt_%04i_%i.png", g_Config.texDumpPath.c_str(), counter++, format);
D3DXSaveTextureToFile(szTemp,D3DXIFF_BMP,entry.texture,0);
}
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp
index df67ebe56b..f4588f91c2 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp
@@ -185,7 +185,7 @@ void CDebugger::CreateGUIControls()
// radio boxes -----------------------------------------------------
- int m_radioBoxNChoices[2];
+ int m_radioBoxNChoices[3];
wxString m_radioBoxChoices0[] = { wxT("Show base 10"), wxT("Show base 16") };
m_radioBoxNChoices[0] = sizeof( m_radioBoxChoices0 ) / sizeof( wxString );
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.h b/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.h
index 0f41efd669..6d908a61dc 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.h
@@ -84,10 +84,10 @@ class CDebugger : public wxDialog
private:
// declarations
- wxCheckBox *m_Check[6];
+ wxCheckBox *m_Check[7];
wxRadioButton *m_Radio[5];
wxRadioBox *m_RadioBox[3];
- wxStaticBox *m_Label[1];
+ wxStaticBox *m_Label[2];
wxPanel *m_Controller;
// WARNING: Make sure these are not also elsewhere, for example in resource.h.
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OpcodeDecoding.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OpcodeDecoding.cpp
index f65714bf49..f46302c6b9 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/OpcodeDecoding.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/OpcodeDecoding.cpp
@@ -51,20 +51,25 @@ static void ExecuteDisplayList(u32 address, u32 size)
u8* old_pVideoData = g_pVideoData;
u8* startAddress = Memory_GetPtr(address);
- g_pVideoData = startAddress;
- // temporarily swap dl and non-dl (small "hack" for the stats)
- Statistics::SwapDL();
-
- while ((u32)(g_pVideoData - startAddress) < size)
- {
- Decode();
- }
- INCSTAT(stats.numDListsCalled);
- INCSTAT(stats.thisFrame.numDListsCalled);
+ //Avoid the crash if Memory_GetPtr failed ..
+ if (startAddress!=0)
+ {
+ g_pVideoData = startAddress;
- // un-swap
- Statistics::SwapDL();
+ // temporarily swap dl and non-dl (small "hack" for the stats)
+ Statistics::SwapDL();
+
+ while ((u32)(g_pVideoData - startAddress) < size)
+ {
+ Decode();
+ }
+ INCSTAT(stats.numDListsCalled);
+ INCSTAT(stats.thisFrame.numDListsCalled);
+
+ // un-swap
+ Statistics::SwapDL();
+ }
// reset to the old pointer
g_pVideoData = old_pVideoData;