Merge pull request #4079 from unknownbrackets/thread-funcs

Fix crash deleting a never started thread w/ clearstack
This commit is contained in:
Henrik Rydgård 2013-10-09 00:47:11 -07:00
commit 996e468562

View File

@ -402,6 +402,7 @@ public:
if (currentStack.start == (u32)-1)
{
currentStack.start = 0;
nt.initialStack = 0;
ERROR_LOG(SCEKERNEL, "Failed to allocate stack for thread");
return false;
}
@ -437,8 +438,8 @@ public:
if (currentStack.start != 0) {
DEBUG_LOG(SCEKERNEL, "Freeing thread stack %s", nt.name);
if (nt.attr & PSP_THREAD_ATTR_CLEAR_STACK) {
Memory::Memset(currentStack.start, 0, currentStack.end - currentStack.start);
if ((nt.attr & PSP_THREAD_ATTR_CLEAR_STACK) != 0 && nt.initialStack != 0) {
Memory::Memset(nt.initialStack, 0, nt.stackSize);
}
if (nt.attr & PSP_THREAD_ATTR_KERNEL) {