mirror of
https://github.com/libretro/snes9x.git
synced 2024-12-03 14:50:57 +00:00
Fix some undefined behavior
The destructor of Resampler needs to be virtual, as it is subclassed and pointers to objects subclassed from it are being deleted. The issue in controls.cpp is that the loop ends up reading past the end of an array. The small rewrite of the loop also makes it more readable. In memmap.cpp, there is an assignment statement of the following form: a[i++] = b[i]; It is undefined what i's value should be in b[i], so this was made explicit.
This commit is contained in:
parent
4080eef6a7
commit
60aabb91d7
@ -17,7 +17,7 @@ class Resampler : public ring_buffer
|
||||
{
|
||||
}
|
||||
|
||||
~Resampler ()
|
||||
virtual ~Resampler ()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -2879,8 +2879,9 @@ void S9xSetJoypadLatch (bool latch)
|
||||
switch (i = curcontrollers[n])
|
||||
{
|
||||
case MP5:
|
||||
for (int j = 0, k = mp5[n].pads[j]; j < 4; k = mp5[n].pads[++j])
|
||||
for (int j = 0, k; j < 4; ++j)
|
||||
{
|
||||
k = mp5[n].pads[j];
|
||||
if (k == NONE)
|
||||
continue;
|
||||
do_polling(k);
|
||||
@ -3170,8 +3171,9 @@ void S9xControlEOF (void)
|
||||
switch (i = curcontrollers[n])
|
||||
{
|
||||
case MP5:
|
||||
for (j = 0, i = mp5[n].pads[j]; j < 4; i = mp5[n].pads[++j])
|
||||
for (j = 0; j < 4; ++j)
|
||||
{
|
||||
i = mp5[n].pads[j];
|
||||
if (i == NONE)
|
||||
continue;
|
||||
|
||||
|
@ -4054,7 +4054,10 @@ static bool8 ReadBPSPatch (Stream *r, long, int32 &rom_size)
|
||||
|
||||
switch((int)mode) {
|
||||
case SourceRead:
|
||||
while(length--) patched_rom[outputOffset++] = Memory.ROM[outputOffset];
|
||||
while(length--) {
|
||||
patched_rom[outputOffset] = Memory.ROM[outputOffset];
|
||||
outputOffset++;
|
||||
}
|
||||
break;
|
||||
case TargetRead:
|
||||
while(length--) patched_rom[outputOffset++] = data[addr++];
|
||||
|
Loading…
Reference in New Issue
Block a user