Merge pull request #4470 from mfleisz/misc_fixes

Various fixes after running VS 2017 code analysis
This commit is contained in:
akallabeth 2018-03-07 14:05:22 +01:00 committed by GitHub
commit dd538ccd4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 64 additions and 42 deletions

View File

@ -716,6 +716,10 @@ static UINT drdynvc_send(drdynvcPlugin* drdynvc, wStream* s)
case CHANNEL_RC_NOT_CONNECTED:
Stream_Free(s, TRUE);
return CHANNEL_RC_OK;
case CHANNEL_RC_BAD_CHANNEL_HANDLE:
Stream_Free(s, TRUE);
WLog_ERR(TAG, "VirtualChannelWriteEx failed with CHANNEL_RC_BAD_CHANNEL_HANDLE");
return status;
default:
Stream_Free(s, TRUE);
@ -1200,7 +1204,7 @@ static void VCAPITYPE drdynvc_virtual_channel_open_event_ex(LPVOID lpUserParam,
if (!drdynvc || (drdynvc->OpenHandle != openHandle))
{
WLog_Print(drdynvc->log, WLOG_ERROR, "drdynvc_virtual_channel_open_event: error no match");
WLog_ERR(TAG, "drdynvc_virtual_channel_open_event: error no match");
Stream_Free((wStream*) pData, TRUE);
return;
}
@ -1527,7 +1531,7 @@ static VOID VCAPITYPE drdynvc_virtual_channel_init_event_ex(LPVOID lpUserParam,
if (!drdynvc || (drdynvc->InitHandle != pInitHandle))
{
WLog_Print(drdynvc->log, WLOG_ERROR, "drdynvc_virtual_channel_init_event: error no match");
WLog_ERR(TAG, "drdynvc_virtual_channel_init_event: error no match");
return;
}
@ -1600,7 +1604,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
if (!drdynvc)
{
WLog_Print(drdynvc->log, WLOG_ERROR, "calloc failed!");
WLog_ERR(TAG, "calloc failed!");
return FALSE;
}

View File

@ -788,7 +788,7 @@ static void* drive_thread_func(void* arg)
}
fail:
if (error && drive->rdpcontext)
if (error && drive && drive->rdpcontext)
setChannelError(drive->rdpcontext, error, "drive_thread_func reported an error");
ExitThread((DWORD)error);

View File

@ -228,7 +228,7 @@ static void* rdpei_schedule_thread(void* arg)
out:
if (error && rdpei->rdpcontext)
if (error && rdpei && rdpei->rdpcontext)
setChannelError(rdpei->rdpcontext, error,
"rdpei_schedule_thread reported an error");

View File

@ -50,11 +50,11 @@ static BOOL nsc_context_initialize_encode(NSC_CONTEXT* context)
{
for (i = 0; i < 5; i++)
{
context->priv->PlaneBuffers[i] = (BYTE*) realloc(context->priv->PlaneBuffers[i],
length);
if (!context->priv->PlaneBuffers[i])
BYTE* tmp = (BYTE*) realloc(context->priv->PlaneBuffers[i], length);
if (!tmp)
goto fail;
context->priv->PlaneBuffers[i] = tmp;
}
context->priv->PlaneBuffersLength = length;

View File

@ -1684,15 +1684,19 @@ INT32 progressive_decompress(PROGRESSIVE_CONTEXT* progressive,
if (region->numRects > progressive->cRects)
{
progressive->rects = (RFX_RECT*) realloc(progressive->rects,
region->numRects * sizeof(RFX_RECT));
BYTE* tmpBuf = (RFX_RECT*) realloc(progressive->rects,
region->numRects * sizeof(RFX_RECT));
if (!tmpBuf)
return -1016;
progressive->rects = tmpBuf;
progressive->cRects = region->numRects;
}
region->rects = progressive->rects;
if (!region->rects)
return -1016;
return -1017;
for (index = 0; index < region->numRects; index++)
{
@ -1705,20 +1709,24 @@ INT32 progressive_decompress(PROGRESSIVE_CONTEXT* progressive,
}
if ((blockLen - boffset) < (region->numQuant * 5))
return -1017;
return -1018;
if (region->numQuant > progressive->cQuant)
{
progressive->quantVals = (RFX_COMPONENT_CODEC_QUANT*) realloc(
BYTE* tmpBuf = (RFX_COMPONENT_CODEC_QUANT*) realloc(
progressive->quantVals,
region->numQuant * sizeof(RFX_COMPONENT_CODEC_QUANT));
if (!tmpBuf)
return -1019;
progressive->quantVals = tmpBuf;
progressive->cQuant = region->numQuant;
}
region->quantVals = progressive->quantVals;
if (!region->quantVals)
return -1018;
return -1020;
for (index = 0; index < region->numQuant; index++)
{
@ -1734,20 +1742,24 @@ INT32 progressive_decompress(PROGRESSIVE_CONTEXT* progressive,
}
if ((blockLen - boffset) < (region->numProgQuant * 16))
return -1019;
return -1021;
if (region->numProgQuant > progressive->cProgQuant)
{
progressive->quantProgVals = (RFX_PROGRESSIVE_CODEC_QUANT*) realloc(
BYTE* tmpBuf = (RFX_PROGRESSIVE_CODEC_QUANT*) realloc(
progressive->quantProgVals,
region->numProgQuant * sizeof(RFX_PROGRESSIVE_CODEC_QUANT));
if (!tmpBuf)
return -1022;
progressive->quantProgVals = tmpBuf;
progressive->cProgQuant = region->numProgQuant;
}
region->quantProgVals = progressive->quantProgVals;
if (!region->quantProgVals)
return -1020;
return -1023;
for (index = 0; index < region->numProgQuant; index++)
{
@ -1763,12 +1775,16 @@ INT32 progressive_decompress(PROGRESSIVE_CONTEXT* progressive,
}
if ((blockLen - boffset) < region->tileDataSize)
return -1021;
return -1024;
if (progressive->cTiles < surface->gridSize)
{
progressive->tiles = (RFX_PROGRESSIVE_TILE**) realloc(progressive->tiles,
BYTE* tmpBuf = (RFX_PROGRESSIVE_TILE**) realloc(progressive->tiles,
surface->gridSize * sizeof(RFX_PROGRESSIVE_TILE*));
if (!tmpBuf)
return -1025;
progressive->tiles = tmpBuf;
progressive->cTiles = surface->gridSize;
}

View File

@ -1622,32 +1622,34 @@ skip_encoding_loop:
}
/* when using threads ensure all computations are done */
message->tilesDataSize = 0;
workObject = context->priv->workObjects;
for (i = 0; i < message->numTiles; i++)
if (success)
{
tile = message->tiles[i];
message->tilesDataSize = 0;
workObject = context->priv->workObjects;
if (context->priv->UseThreads)
for (i = 0; i < message->numTiles; i++)
{
if (*workObject)
tile = message->tiles[i];
if (context->priv->UseThreads)
{
WaitForThreadpoolWorkCallbacks(*workObject, FALSE);
CloseThreadpoolWork(*workObject);
if (*workObject)
{
WaitForThreadpoolWorkCallbacks(*workObject, FALSE);
CloseThreadpoolWork(*workObject);
}
workObject++;
}
workObject++;
message->tilesDataSize += rfx_tile_length(tile);
}
message->tilesDataSize += rfx_tile_length(tile);
}
region16_uninit(&tilesRegion);
region16_uninit(&rectsRegion);
region16_uninit(&tilesRegion);
region16_uninit(&rectsRegion);
if (success)
return message;
}
WLog_ERR(TAG, "%s: failed", __FUNCTION__);
message->freeRects = TRUE;

View File

@ -1424,7 +1424,7 @@ static BOOL nla_encode_ts_credentials(rdpNla* nla)
nla_write_ts_credentials(nla, s);
if (nla->settings->DisableCredentialsDelegation)
if (nla->settings->DisableCredentialsDelegation && nla->identity)
{
/* TSPasswordCreds */
nla->identity->DomainLength = DomainLength;

View File

@ -162,7 +162,7 @@ static const BYTE BPP_CBR23[] =
static const BYTE BMF_BPP[] =
{
0, 1, 0, 8, 16, 24, 32
0, 1, 0, 8, 16, 24, 32, 0
};
static const BYTE BPP_BMF[] =
@ -566,7 +566,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush,
if (brush->style & CACHED_BRUSH)
{
brush->index = brush->hatch;
brush->bpp = BMF_BPP[brush->style & 0x0F];
brush->bpp = BMF_BPP[brush->style & 0x07];
if (brush->bpp == 0)
brush->bpp = 1;
@ -612,7 +612,7 @@ static INLINE BOOL update_write_brush(wStream* s, rdpBrush* brush,
if (brush->style & CACHED_BRUSH)
{
brush->hatch = brush->index;
brush->bpp = BMF_BPP[brush->style & 0x0F];
brush->bpp = BMF_BPP[brush->style & 0x07];
if (brush->bpp == 0)
brush->bpp = 1;

View File

@ -424,10 +424,10 @@ char** winpr_backtrace_symbols(void* buffer, size_t* used)
if (SymGetLineFromAddr64(process, address, &displacement, line))
{
sprintf_s(vlines[i], line_len, "%08lX: %s in %s:%lu", symbol->Address, symbol->Name, line->FileName, line->LineNumber);
sprintf_s(vlines[i], line_len, "%016"PRIx64": %s in %s:%"PRIu32, symbol->Address, symbol->Name, line->FileName, line->LineNumber);
}
else
sprintf_s(vlines[i], line_len, "%08lX: %s", symbol->Address, symbol->Name);
sprintf_s(vlines[i], line_len, "%016"PRIx64": %s", symbol->Address, symbol->Name);
}
if (used)