Merge pull request #2728 from bmiklautz/unsigned

Fix possible endless loops on cleanup.
This commit is contained in:
Norbert Federa 2015-06-25 12:11:50 +02:00
commit a4c9a7f604
3 changed files with 13 additions and 10 deletions

View File

@ -107,10 +107,9 @@ static BOOL update_message_BitmapUpdate(rdpContext* context, BITMAP_UPDATE* bitm
wParam->rectangles[index].bitmapDataStream = (BYTE*) malloc(wParam->rectangles[index].bitmapLength); wParam->rectangles[index].bitmapDataStream = (BYTE*) malloc(wParam->rectangles[index].bitmapLength);
if (!wParam->rectangles[index].bitmapDataStream) if (!wParam->rectangles[index].bitmapDataStream)
{ {
for (index -= 1; index >= 0; --index) while(index)
{ free(wParam->rectangles[--index].bitmapDataStream);
free(wParam->rectangles[index].bitmapDataStream);
}
free(wParam->rectangles); free(wParam->rectangles);
free(wParam); free(wParam);
return FALSE; return FALSE;

View File

@ -755,8 +755,9 @@ rdpSettings* freerdp_settings_clone(rdpSettings* settings)
_settings->TargetNetAddresses[index] = _strdup(settings->TargetNetAddresses[index]); _settings->TargetNetAddresses[index] = _strdup(settings->TargetNetAddresses[index]);
if (!_settings->TargetNetAddresses[index]) if (!_settings->TargetNetAddresses[index])
{ {
for (--index; index >= 0; --index) while(index)
free(_settings->TargetNetAddresses[index]); free(_settings->TargetNetAddresses[--index]);
free(_settings->TargetNetAddresses); free(_settings->TargetNetAddresses);
_settings->TargetNetAddresses = NULL; _settings->TargetNetAddresses = NULL;
_settings->TargetNetAddressCount = 0; _settings->TargetNetAddressCount = 0;

View File

@ -364,9 +364,9 @@ BOOL ClipboardInitFormats(wClipboard* clipboard)
if (!clipboard) if (!clipboard)
return FALSE; return FALSE;
for (formatId = 0; formatId < CF_MAX; formatId++) for (formatId = 0; formatId < CF_MAX; formatId++, clipboard->numFormats++)
{ {
format = &(clipboard->formats[clipboard->numFormats++]); format = &(clipboard->formats[clipboard->numFormats]);
ZeroMemory(format, sizeof(wClipboardFormat)); ZeroMemory(format, sizeof(wClipboardFormat));
format->formatId = formatId; format->formatId = formatId;
@ -374,9 +374,12 @@ BOOL ClipboardInitFormats(wClipboard* clipboard)
if (!format->formatName) if (!format->formatName)
{ {
for (--formatId; formatId >= 0; --formatId) int i;
for (i = formatId-1; i >= 0; --i)
{
format = &(clipboard->formats[--clipboard->numFormats]);
free((void *)format->formatName); free((void *)format->formatName);
clipboard->numFormats = 0; }
return FALSE; return FALSE;
} }
} }