diff --git a/channels/urbdrc/client/searchman.c b/channels/urbdrc/client/searchman.c index e4b2b7d73..f58066035 100644 --- a/channels/urbdrc/client/searchman.c +++ b/channels/urbdrc/client/searchman.c @@ -190,6 +190,8 @@ USB_SEARCHMAN* searchman_new(void * urbdrc, UINT32 UsbDevice) USB_SEARCHMAN* searchman; searchman = (USB_SEARCHMAN*) malloc(sizeof(USB_SEARCHMAN)); + if (!searchman) + return NULL; searchman->idev = NULL; searchman->head = NULL; @@ -199,11 +201,10 @@ USB_SEARCHMAN* searchman_new(void * urbdrc, UINT32 UsbDevice) searchman->UsbDevice = UsbDevice; ret = pthread_mutex_init(&searchman->mutex, NULL); - if (ret != 0) { - WLog_ERR(TAG, "searchman mutex initialization: searchman->mutex failed"); - exit(EXIT_FAILURE); + WLog_ERR(TAG, "searchman mutex initialization: searchman->mutex failed"); + goto out_error_mutex; } /* load service */ @@ -219,7 +220,15 @@ USB_SEARCHMAN* searchman_new(void * urbdrc, UINT32 UsbDevice) searchman->strated = 0; searchman->term_event = CreateEvent(NULL, TRUE, FALSE, NULL); + if (!searchman->term_event) + goto out_error_event; sem_init(&searchman->sem_term, 0, 0); return searchman; + +out_error_event: + pthread_mutex_destroy(&searchman->mutex); +out_error_mutex: + free(searchman); + return NULL; } diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index e93fe087a..308a84137 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -230,7 +230,7 @@ static BOOL freerdp_peer_initialize(freerdp_peer* client) { WLog_ERR(TAG, "Key sizes > 2048 are currently not supported for RDP security."); WLog_ERR(TAG, "Set a different key file than %s", settings->RdpKeyFile); - exit(1); + return FALSE; } }