diff options
author | dankcushions | 2016-05-13 16:21:37 +0100 |
---|---|---|
committer | cbransden | 2016-05-13 18:30:02 +0100 |
commit | bebaef4be9a87d92b11bc29a002a531a9d1fa5d7 (patch) | |
tree | 268c11889974c4dda4518c85eff7cf45b2e14dd2 | |
parent | 6f1d3c7a18600c59227b3373a5205841174f8e44 (diff) | |
download | pcsx_rearmed-bebaef4be9a87d92b11bc29a002a531a9d1fa5d7.tar.gz pcsx_rearmed-bebaef4be9a87d92b11bc29a002a531a9d1fa5d7.tar.bz2 pcsx_rearmed-bebaef4be9a87d92b11bc29a002a531a9d1fa5d7.zip |
Defensive code to avoid SEGFAULT
-rw-r--r-- | frontend/plugin.c | 7 | ||||
-rw-r--r-- | libpcsxcore/plugins.c | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/frontend/plugin.c b/frontend/plugin.c index cf93df8..53ecac9 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -67,7 +67,12 @@ static long PADreadPort1(PadDataS *pad, int pad_index) { } static long PADreadPort2(PadDataS *pad, int pad_index) { - pad->controllerType = in_type[pad_index]; + /* Temporary hack to avoid segfault when pad_index is a crazy number */ + if (pad_index <= 1 || pad_index > 8) { + pad_index = 1; + } + + pad->controllerType = in_type[pad_index]; pad->buttonStatus = ~in_keystate[pad_index]; if(multitap2==1){ pad->portMultitap=2; diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 3d0ed3c..1369b1c 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -384,8 +384,8 @@ static int bufcount, bufc; //PadDataS padd1, padd2;
unsigned char _PADstartPollMultitap(PadDataS padd[4]) {
- int i=0;
- int decallage=2;
+ int i=0;
+ int decallage=2;
bufc = 0;
PadDataS pad;
for(i=0;i<4;i++){
@@ -626,7 +626,7 @@ unsigned char CALLBACK PAD2__startPoll(int pad) { return _PADstartPoll(&padd);
}else{
//a multitap is plugged : refresh all pad.
- int i=pad_index;
+ int i=0;
PadDataS padd[4];
for(i=0;i<4;i++){
PAD2_readPort2(&padd[i],i+pad_index);
|