fixed static analysis errors reported by Visual Studio 2015
This commit is contained in:
parent
7d47fc87f1
commit
8ad3792af0
@ -76,6 +76,8 @@ int main(int argc, char** argv)
|
|||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
path = (char*)malloc(length + 1);
|
path = (char*)malloc(length + 1);
|
||||||
|
if (!path)
|
||||||
|
abort();
|
||||||
wai_getExecutablePath(path, length, &dirname_length);
|
wai_getExecutablePath(path, length, &dirname_length);
|
||||||
path[length] = '\0';
|
path[length] = '\0';
|
||||||
|
|
||||||
@ -90,6 +92,8 @@ int main(int argc, char** argv)
|
|||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
path = (char*)malloc(length + 1);
|
path = (char*)malloc(length + 1);
|
||||||
|
if (!path)
|
||||||
|
abort();
|
||||||
wai_getModulePath(path, length, &dirname_length);
|
wai_getModulePath(path, length, &dirname_length);
|
||||||
path[length] = '\0';
|
path[length] = '\0';
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ extern "C" {
|
|||||||
|
|
||||||
static int WAI_PREFIX(getModulePath_)(HMODULE module, char* out, int capacity, int* dirname_length)
|
static int WAI_PREFIX(getModulePath_)(HMODULE module, char* out, int capacity, int* dirname_length)
|
||||||
{
|
{
|
||||||
wchar_t buffer1[MAX_PATH];
|
wchar_t buffer1[1];
|
||||||
wchar_t buffer2[MAX_PATH];
|
wchar_t buffer2[MAX_PATH];
|
||||||
wchar_t* path = NULL;
|
wchar_t* path = NULL;
|
||||||
int length = -1;
|
int length = -1;
|
||||||
@ -77,15 +77,25 @@ static int WAI_PREFIX(getModulePath_)(HMODULE module, char* out, int capacity, i
|
|||||||
DWORD size_ = size;
|
DWORD size_ = size;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
wchar_t* path_;
|
||||||
|
|
||||||
|
path_ = (wchar_t*)WAI_REALLOC(path, sizeof(wchar_t) * size_ * 2);
|
||||||
|
if (!path_)
|
||||||
|
break;
|
||||||
size_ *= 2;
|
size_ *= 2;
|
||||||
path = (wchar_t*)WAI_REALLOC(path, sizeof(wchar_t) * size_);
|
path = path_;
|
||||||
size = GetModuleFileNameW(NULL, path, size_);
|
size = GetModuleFileNameW(module, path, size_);
|
||||||
} while (size == size_);
|
}
|
||||||
|
while (size == size_);
|
||||||
|
|
||||||
|
if (size == size_)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
path = buffer1;
|
path = buffer1;
|
||||||
|
|
||||||
_wfullpath(buffer2, path, MAX_PATH);
|
if (!_wfullpath(buffer2, path, MAX_PATH))
|
||||||
|
break;
|
||||||
length_ = WideCharToMultiByte(CP_UTF8, 0, buffer2, -1, out, capacity, NULL, NULL);
|
length_ = WideCharToMultiByte(CP_UTF8, 0, buffer2, -1, out, capacity, NULL, NULL);
|
||||||
|
|
||||||
if (length_ == 0)
|
if (length_ == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user