client/windows: do not fail in buffer exhaused

This commit is contained in:
Oleksii Shevchuk 2019-08-19 22:57:48 +03:00
parent 23165e6ff6
commit 18aeb3a12a
1 changed files with 6 additions and 3 deletions

View File

@ -110,13 +110,16 @@ LPSTR* CommandLineToArgvA(INT *pNumArgs)
return NULL;
}
bufLen = storage - numArgs * sizeof(LPSTR);
buffer = ((LPSTR)result) + numArgs * sizeof(LPSTR);
bufLen = storage - (numArgs * sizeof(LPSTR));
buffer = ((LPSTR)result) + (numArgs * sizeof(LPSTR));
for (i = 0; i < numArgs; ++ i)
{
BOOL lpUsedDefaultChar = FALSE;
assert(bufLen > 0);
if (bufLen < 0) {
dprint("Buflen exhaused, arg %d (%d/%d)\n", i, bufLen, storage);
break;
}
retval = WideCharToMultiByte(
CP_UTF8, 0, args[i], -1, buffer,