PSP: Fix Minor Memory Access Error and Leaks in Backend Code.
This is as per bug Trac #10654.
This commit is contained in:
parent
5390c258d2
commit
9c1dfe41aa
2 changed files with 32 additions and 1 deletions
|
@ -117,9 +117,9 @@ void VramAllocator::deallocate(void *address) {
|
|||
// Find the Allocator to deallocate
|
||||
for (i = _allocList.begin(); i != _allocList.end(); ++i) {
|
||||
if ((*i).address == address) {
|
||||
PSP_DEBUG_PRINT("Deallocated address[%p], size[%u]\n", (*i).address, (*i).size);
|
||||
_bytesAllocated -= (*i).size;
|
||||
_allocList.erase(i);
|
||||
PSP_DEBUG_PRINT("Deallocated address[%p], size[%u]\n", (*i).address, (*i).size);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -566,6 +566,7 @@ bool PspUnitTests::testFileSystem() {
|
|||
wrStream = file.createWriteStream();
|
||||
if (!wrStream) {
|
||||
PSP_ERROR("%s couldn't be created.\n", path);
|
||||
delete[] buffer;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -579,6 +580,8 @@ bool PspUnitTests::testFileSystem() {
|
|||
while(totalLength - curLength > 0) {
|
||||
if ((int)wrStream->write(index, curLength) != curLength) {
|
||||
PSP_ERROR("couldn't write %d bytes\n", curLength);
|
||||
delete[] buffer;
|
||||
delete wrStream;
|
||||
return false;
|
||||
}
|
||||
totalLength -= curLength;
|
||||
|
@ -590,6 +593,8 @@ bool PspUnitTests::testFileSystem() {
|
|||
// write the rest
|
||||
if ((int)wrStream->write(index, totalLength) != totalLength) {
|
||||
PSP_ERROR("couldn't write %d bytes\n", curLength);
|
||||
delete[] buffer;
|
||||
delete wrStream;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -600,12 +605,15 @@ bool PspUnitTests::testFileSystem() {
|
|||
rdStream = file.createReadStream();
|
||||
if (!rdStream) {
|
||||
PSP_ERROR("%s couldn't be created.\n", path);
|
||||
delete[] buffer;
|
||||
return false;
|
||||
}
|
||||
|
||||
// seek to beginning
|
||||
if (!rdStream->seek(0, SEEK_SET)) {
|
||||
PSP_ERROR("couldn't seek to the beginning after writing the file\n");
|
||||
delete[] buffer;
|
||||
delete rdStream;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -619,6 +627,9 @@ bool PspUnitTests::testFileSystem() {
|
|||
|
||||
if (!rdStream->eos()) {
|
||||
PSP_ERROR("didn't find EOS at end of stream\n");
|
||||
delete[] buffer;
|
||||
delete rdStream;
|
||||
delete[] readBuffer;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -626,6 +637,9 @@ bool PspUnitTests::testFileSystem() {
|
|||
for (i=0; i<(int)BufSize; i++)
|
||||
if (buffer[i] != readBuffer[i]) {
|
||||
PSP_ERROR("reading/writing mistake at %x. Got %x instead of %x\n", i, readBuffer[i], buffer[i]);
|
||||
delete[] buffer;
|
||||
delete rdStream;
|
||||
delete[] readBuffer;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -636,7 +650,9 @@ bool PspUnitTests::testFileSystem() {
|
|||
}
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
delete rdStream;
|
||||
delete[] readBuffer;
|
||||
|
||||
PSP_INFO_PRINT("writing...\n");
|
||||
|
||||
|
@ -652,12 +668,14 @@ bool PspUnitTests::testFileSystem() {
|
|||
int ret;
|
||||
if ((ret = wrStream->write(phrase, phraseLen)) != (int)phraseLen) {
|
||||
PSP_ERROR("couldn't write phrase. Got %d instead of %d\n", ret, phraseLen);
|
||||
delete wrStream;
|
||||
return false;
|
||||
}
|
||||
|
||||
PSP_INFO_PRINT("reading...\n");
|
||||
|
||||
delete wrStream;
|
||||
|
||||
rdStream = file.createReadStream();
|
||||
if (!rdStream) {
|
||||
PSP_ERROR("%s couldn't be created.\n", path);
|
||||
|
@ -669,12 +687,16 @@ bool PspUnitTests::testFileSystem() {
|
|||
|
||||
if ((ret = rdStream->read(readPhrase, phraseLen) != phraseLen)) {
|
||||
PSP_ERROR("read error on phrase. Got %d instead of %d\n", ret, phraseLen);
|
||||
delete rdStream;
|
||||
delete[] readPhrase;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i=0; i<(int)phraseLen; i++) {
|
||||
if (readPhrase[i] != phrase[i]) {
|
||||
PSP_ERROR("bad read/write in phrase. At %d, %x != %x\n", i, readPhrase[i], phrase[i]);
|
||||
delete rdStream;
|
||||
delete[] readPhrase;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -682,6 +704,8 @@ bool PspUnitTests::testFileSystem() {
|
|||
// check for exceeding
|
||||
if (readPhrase[i] != 0) {
|
||||
PSP_ERROR("found excessive copy in phrase. %c at %d\n", readPhrase[i], i);
|
||||
delete rdStream;
|
||||
delete[] readPhrase;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -690,15 +714,22 @@ bool PspUnitTests::testFileSystem() {
|
|||
// seek to end
|
||||
if (!rdStream->seek(0, SEEK_END)) {
|
||||
PSP_ERROR("couldn't seek to end for append\n");
|
||||
delete rdStream;
|
||||
delete[] readPhrase;
|
||||
return false;
|
||||
};
|
||||
|
||||
// try to read
|
||||
if (rdStream->read(readPhrase, 2) || !rdStream->eos()) {
|
||||
PSP_ERROR("was able to read at end of file\n");
|
||||
delete rdStream;
|
||||
delete[] readPhrase;
|
||||
return false;
|
||||
}
|
||||
|
||||
delete rdStream;
|
||||
delete[] readPhrase;
|
||||
|
||||
PSP_INFO_PRINT("ok\n");
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue