Fix OOM situation

This commit is contained in:
Hardening 2014-05-21 15:54:25 +02:00
parent 9c18ae5bee
commit 0376dcd065

View File

@ -1056,26 +1056,29 @@ rdpMcs* mcs_new(rdpTransport* transport)
{ {
rdpMcs* mcs; rdpMcs* mcs;
mcs = (rdpMcs*) malloc(sizeof(rdpMcs)); mcs = (rdpMcs *)calloc(1, sizeof(rdpMcs));
if (!mcs)
return NULL;
if (mcs) mcs->transport = transport;
{ mcs->settings = transport->settings;
ZeroMemory(mcs, sizeof(rdpMcs));
mcs->transport = transport; mcs_init_domain_parameters(&mcs->targetParameters, 34, 2, 0, 0xFFFF);
mcs->settings = transport->settings; mcs_init_domain_parameters(&mcs->minimumParameters, 1, 1, 1, 0x420);
mcs_init_domain_parameters(&mcs->maximumParameters, 0xFFFF, 0xFC17, 0xFFFF, 0xFFFF);
mcs_init_domain_parameters(&mcs->domainParameters, 0, 0, 0, 0xFFFF);
mcs_init_domain_parameters(&mcs->targetParameters, 34, 2, 0, 0xFFFF); mcs->channelCount = 0;
mcs_init_domain_parameters(&mcs->minimumParameters, 1, 1, 1, 0x420); mcs->channelMaxCount = CHANNEL_MAX_COUNT;
mcs_init_domain_parameters(&mcs->maximumParameters, 0xFFFF, 0xFC17, 0xFFFF, 0xFFFF); mcs->channels = (rdpMcsChannel *)calloc(mcs->channelMaxCount, sizeof(rdpMcsChannel));
mcs_init_domain_parameters(&mcs->domainParameters, 0, 0, 0, 0xFFFF); if (!mcs->channels)
goto out_free;
mcs->channelCount = 0;
mcs->channelMaxCount = CHANNEL_MAX_COUNT;
mcs->channels = (rdpMcsChannel*) calloc(mcs->channelMaxCount, sizeof(rdpMcsChannel));
}
return mcs; return mcs;
out_free:
free(mcs);
return NULL;
} }
/** /**