channels/smartcard: Fix leak found by covscan
authorOndrej Holy <oholy@redhat.com>
Fri, 17 Aug 2018 12:19:19 +0000 (14:19 +0200)
committerOndrej Holy <oholy@redhat.com>
Wed, 22 Aug 2018 11:35:43 +0000 (13:35 +0200)
leaked_storage: Variable "operation" going out of scope leaks the storage it points to.

channels/smartcard/client/smartcard_main.c

index 2a5bc8d..37a223e 100644 (file)
@@ -377,10 +377,12 @@ UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
 
                        if (!Queue_Enqueue(smartcard->CompletedIrpQueue, (void*) irp))
                        {
+                               free(operation);
                                WLog_ERR(TAG, "Queue_Enqueue failed!");
                                return ERROR_INTERNAL_ERROR;
                        }
 
+                       free(operation);
                        return CHANNEL_RC_OK;
                }
 
@@ -460,6 +462,7 @@ UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
 
                        if (!Queue_Enqueue(smartcard->CompletedIrpQueue, (void*) irp))
                        {
+                               free(operation);
                                WLog_ERR(TAG, "Queue_Enqueue failed!");
                                return ERROR_INTERNAL_ERROR;
                        }