Fixed getTempPath.

This commit is contained in:
Branimir Karadžić
2017-01-04 20:09:53 -08:00
parent 1e6e3eda86
commit 541ec1c9fe
2 changed files with 13 additions and 8 deletions

View File

@@ -237,14 +237,16 @@ namespace bx
#else
const char* ptr = ::getenv(_name);
uint32_t len = 0;
bool result = false;
if (NULL != ptr)
{
len = (uint32_t)strlen(ptr);
}
bool result = len != 0 && len < *_inOutSize;
if (len < *_inOutSize)
{
strcpy(_out, ptr);
result = len != 0 && len < *_inOutSize;
if (len < *_inOutSize)
{
strcpy(_out, ptr);
}
}
*_inOutSize = len;
@@ -324,11 +326,14 @@ namespace bx
NULL
};
for (const char** tmp = s_tmp; tmp != NULL; ++tmp)
for (const char** tmp = s_tmp; *tmp != NULL; ++tmp)
{
uint32_t len = *_inOutSize;
*_out = '\0';
bool result = getenv(*tmp, _out, &len);
if (len != 0
if (result
&& len != 0
&& len < *_inOutSize)
{
*_inOutSize = len;

View File

@@ -6,7 +6,7 @@ TEST(getProcessMemoryUsed)
CHECK(0 != bx::getProcessMemoryUsed() );
// DBG("bx::getProcessMemoryUsed %d", bx::getProcessMemoryUsed() );
char tmpDir[PATH_MAX];
char tmpDir[512];
uint32_t len = BX_COUNTOF(tmpDir);
CHECK(bx::getTempPath(tmpDir, &len) );
}