mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-27 07:20:49 +00:00
Fix some resource leaks/memory leaks.
This commit is contained in:
parent
4c313e31ac
commit
b897309eaf
@ -44,6 +44,8 @@ char *GetCPUString()
|
||||
// INFO_LOG(BOOT, "CPU: %s", cpu_string);
|
||||
break;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return cpu_string;
|
||||
}
|
||||
bool CheckCPUFeature(const char *feature)
|
||||
@ -69,6 +71,8 @@ bool CheckCPUFeature(const char *feature)
|
||||
token = strtok(NULL, " ");
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@ -94,6 +98,8 @@ int GetCoreCount()
|
||||
continue;
|
||||
++cores;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return cores;
|
||||
#endif
|
||||
}
|
||||
|
@ -567,12 +567,24 @@ bool DeleteDirRecursively(const std::string &directory)
|
||||
if (IsDirectory(newPath))
|
||||
{
|
||||
if (!DeleteDirRecursively(newPath))
|
||||
{
|
||||
#ifndef _WIN32
|
||||
closedir(dirp);
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!File::Delete(newPath))
|
||||
{
|
||||
#ifndef _WIN32
|
||||
closedir(dirp);
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -42,16 +42,20 @@ static inline int vasprintf(char **rResult, const char *aFormat, va_list aAp)
|
||||
rVal = vsnprintf(result, 16, aFormat, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (rVal == -1) return rVal;
|
||||
if (rVal == -1)
|
||||
{
|
||||
free(result);
|
||||
return rVal;
|
||||
}
|
||||
else if (rVal >= 16)
|
||||
{
|
||||
free(result);
|
||||
result = (char *) malloc(rVal + 1);
|
||||
if (result == NULL) return -1;
|
||||
free(result);
|
||||
result = (char *) malloc(rVal + 1);
|
||||
if (result == NULL) return -1;
|
||||
|
||||
va_copy(ap, aAp);
|
||||
rVal = vsnprintf(result, rVal + 1, aFormat, aAp);
|
||||
va_end(ap);
|
||||
va_copy(ap, aAp);
|
||||
rVal = vsnprintf(result, rVal + 1, aFormat, aAp);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
*rResult = result;
|
||||
|
Loading…
Reference in New Issue
Block a user