Fix possible NULL pointer access crash
authorMartin Fleisz <martin.fleisz@thincast.com>
Fri, 28 Feb 2020 10:22:36 +0000 (11:22 +0100)
committerakallabeth <akallabeth@users.noreply.github.com>
Fri, 28 Feb 2020 11:53:39 +0000 (12:53 +0100)
channels/rdpsnd/client/rdpsnd_main.c

index 53129e7..a6bbefd 100644 (file)
@@ -1125,9 +1125,9 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex(LPVOID lpUserParam, D
        if (error && rdpsnd && rdpsnd->rdpcontext)
        {
                char buffer[8192];
-               snprintf(buffer, sizeof(buffer),
-                        "%s rdpsnd_virtual_channel_open_event_ex reported an error",
-                        rdpsnd_is_dyn_str(rdpsnd->dynamic));
+               _snprintf(buffer, sizeof(buffer),
+                         "%s rdpsnd_virtual_channel_open_event_ex reported an error",
+                         rdpsnd_is_dyn_str(rdpsnd->dynamic));
                setChannelError(rdpsnd->rdpcontext, error, buffer);
        }
 }
@@ -1185,7 +1185,8 @@ static UINT rdpsnd_virtual_channel_event_disconnected(rdpsndPlugin* rdpsnd)
        if (rdpsnd->OpenHandle == 0)
                return CHANNEL_RC_OK;
 
-       IFCALL(rdpsnd->device->Close, rdpsnd->device);
+       if (rdpsnd->device)
+               IFCALL(rdpsnd->device->Close, rdpsnd->device);
 
        error =
            rdpsnd->channelEntryPoints.pVirtualChannelCloseEx(rdpsnd->InitHandle, rdpsnd->OpenHandle);
@@ -1276,8 +1277,8 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_init_event_ex(LPVOID lpUserParam, L
        if (error && plugin && plugin->rdpcontext)
        {
                char buffer[8192];
-               snprintf(buffer, sizeof(buffer), "%s %s reported an error",
-                        rdpsnd_is_dyn_str(plugin->dynamic), __FUNCTION__);
+               _snprintf(buffer, sizeof(buffer), "%s %s reported an error",
+                         rdpsnd_is_dyn_str(plugin->dynamic), __FUNCTION__);
                setChannelError(plugin->rdpcontext, error, buffer);
        }
 }
@@ -1374,7 +1375,8 @@ static UINT rdpsnd_on_close(IWTSVirtualChannelCallback* pChannelCallback)
        RDPSND_CHANNEL_CALLBACK* callback = (RDPSND_CHANNEL_CALLBACK*)pChannelCallback;
        rdpsndPlugin* rdpsnd = (rdpsndPlugin*)callback->plugin;
 
-       IFCALL(rdpsnd->device->Close, rdpsnd->device);
+       if (rdpsnd->device)
+               IFCALL(rdpsnd->device->Close, rdpsnd->device);
        freerdp_dsp_context_free(rdpsnd->dsp_context);
        StreamPool_Return(rdpsnd->pool, rdpsnd->data_in);
        StreamPool_Free(rdpsnd->pool);