Fixed memory leak.

This commit is contained in:
Armin Novak 2015-08-28 11:17:20 +02:00
parent 5cad081cc8
commit 5e360ddcb1

View File

@ -450,7 +450,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
if ((error = rdpdr_send_device_list_remove_request(rdpdr, 1, ids)))
{
WLog_ERR(TAG, "rdpdr_send_device_list_remove_request failed with error %lu!", error);
return error;
goto cleanup;
}
}
}
@ -468,10 +468,8 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
if (!drive)
{
WLog_ERR(TAG, "calloc failed!");
free(dev_array[i].path);
dev_array[i].path = NULL;
return CHANNEL_RC_NO_MEMORY;
error = CHANNEL_RC_NO_MEMORY;
goto cleanup;
}
drive->Type = RDPDR_DTYP_FILESYSTEM;
@ -483,7 +481,8 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
{
WLog_ERR(TAG, "_strdup failed!");
free(drive);
return CHANNEL_RC_NO_MEMORY;
error = CHANNEL_RC_NO_MEMORY;
goto cleanup;
}
name = strrchr(drive->Path, '/') + 1;
drive->Name = _strdup(name);
@ -492,7 +491,8 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
WLog_ERR(TAG, "_strdup failed!");
free(drive->Path);
free(drive);
return CHANNEL_RC_NO_MEMORY;
error = CHANNEL_RC_NO_MEMORY;
goto cleanup;
}
if ((error = devman_load_device_service(rdpdr->devman, (RDPDR_DEVICE *)drive, rdpdr->rdpcontext)))
{
@ -500,11 +500,22 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
free(drive->Path);
free(drive->Name);
free(drive);
return error;
error = CHANNEL_RC_NO_MEMORY;
goto cleanup;
}
}
}
for (i = 0; i < size; i++)
free (dev_array[size].path);
return rdpdr_send_device_list_announce_request(rdpdr, TRUE);
cleanup:
for (i = 0; i < size; i++)
free (dev_array[size].path);
return error;
}
static void* drive_hotplug_thread_func(void* arg)