[PATCH] hidclass.sys: add missing case/missing heapfree (Coverity)

Aric Stewart aric at codeweavers.com
Thu Apr 21 06:18:57 CDT 2016


On 4/20/16 1:16 PM, Marcus Meissner wrote:
> 1358558 Resource leak
> 
> (actually switch on the enum, then the compiler will see missing cases)
> 
> Signed-off-by: Marcus Meissner <marcus at jet.franken.de>
> ---
>   dlls/hidclass.sys/pnp.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c
> index d97184f..9ada261 100644
> --- a/dlls/hidclass.sys/pnp.c
> +++ b/dlls/hidclass.sys/pnp.c
> @@ -295,7 +295,7 @@ NTSTATUS WINAPI HID_PNP_Dispatch(DEVICE_OBJECT *device, IRP *irp)
>               ULONG type = irpsp->Parameters.QueryId.IdType;
>               WCHAR *id = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR)*REGSTR_VAL_MAX_HCID_LEN);
>               TRACE("IRP_MN_QUERY_ID[%i]\n", type);
> -            switch (type)
> +            switch (irpsp->Parameters.QueryId.IdType)
>               {
>                   case BusQueryHardwareIDs:
>                   case BusQueryCompatibleIDs:
> @@ -326,6 +326,10 @@ NTSTATUS WINAPI HID_PNP_Dispatch(DEVICE_OBJECT *device, IRP *irp)
>                       irp->IoStatus.Information = (ULONG_PTR)id;
>                       rc = STATUS_SUCCESS;
>                       break;
> +                case BusQueryDeviceSerialNumber:
> +                    FIXME("BusQueryDeviceSerialNumber not implemented\n");
> +                    HeapFree(GetProcessHeap(), 0, id);
> +                    break;
>               }
>               break;
>           }
> 


If we are switching on the irpsp->Parameters.QueryId.IdType then maybe we should remove the "type" variable all together? It is only used in the TRACE statement then.

-aric



More information about the wine-devel mailing list