Fixed NULL pointer checks.
authorArmin Novak <armin.novak@thincast.com>
Tue, 4 Oct 2016 08:31:04 +0000 (10:31 +0200)
committerArmin Novak <armin.novak@thincast.com>
Thu, 6 Oct 2016 11:43:14 +0000 (13:43 +0200)
channels/audin/server/audin.c
channels/rdpsnd/client/rdpsnd_main.c

index 015e330..39d4c7d 100644 (file)
@@ -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++)
        {
index db5aa6b..f5f7a03 100644 (file)
@@ -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);