From b03e47166e95ea9a9f1451f237a527d1d82ee362 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 4 Oct 2016 10:31:04 +0200 Subject: [PATCH] Fixed NULL pointer checks. --- channels/audin/server/audin.c | 7 ++++--- channels/rdpsnd/client/rdpsnd_main.c | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index 015e33071..39d4c7da4 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -224,10 +224,11 @@ static UINT audin_server_recv_formats(audin_server* audin, wStream* s, return ERROR_INVALID_DATA; } - audin->context.client_formats = malloc(audin->context.num_client_formats * + audin->context.client_formats = calloc(audin->context.num_client_formats, sizeof(AUDIO_FORMAT)); - ZeroMemory(audin->context.client_formats, - audin->context.num_client_formats * sizeof(AUDIO_FORMAT)); + + if (!audin->context.client_formats) + return ERROR_NOT_ENOUGH_MEMORY; for (i = 0; i < audin->context.num_client_formats; i++) { diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index db5aa6bdf..f5f7a0301 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -224,9 +224,12 @@ static void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd) if (!rdpsnd->NumberOfServerFormats) return; - rdpsnd->ClientFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * + rdpsnd->ClientFormats = (AUDIO_FORMAT*) calloc(sizeof(AUDIO_FORMAT), rdpsnd->NumberOfServerFormats); + if (!rdpsnd->ClientFormats) + return; + for (index = 0; index < (int) rdpsnd->NumberOfServerFormats; index++) { serverFormat = &rdpsnd->ServerFormats[index]; @@ -799,7 +802,6 @@ static UINT rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name, { PFREERDP_RDPSND_DEVICE_ENTRY entry; FREERDP_RDPSND_DEVICE_ENTRY_POINTS entryPoints; - \ UINT error; entry = (PFREERDP_RDPSND_DEVICE_ENTRY) freerdp_load_channel_addin_entry("rdpsnd", (LPSTR) name, NULL, 0);