[server,shadow] add return checks
add return checks and simplified cleanup for shadow_screen_new
This commit is contained in:
parent
e6363649e0
commit
1caa439a54
@ -226,8 +226,9 @@ int shadow_capture_compare(BYTE* pData1, UINT32 nStep1, UINT32 nWidth, UINT32 nH
|
||||
|
||||
rdpShadowCapture* shadow_capture_new(rdpShadowServer* server)
|
||||
{
|
||||
rdpShadowCapture* capture;
|
||||
capture = (rdpShadowCapture*)calloc(1, sizeof(rdpShadowCapture));
|
||||
WINPR_ASSERT(server);
|
||||
|
||||
rdpShadowCapture* capture = (rdpShadowCapture*)calloc(1, sizeof(rdpShadowCapture));
|
||||
|
||||
if (!capture)
|
||||
return NULL;
|
||||
@ -236,7 +237,7 @@ rdpShadowCapture* shadow_capture_new(rdpShadowServer* server)
|
||||
|
||||
if (!InitializeCriticalSectionAndSpinCount(&(capture->lock), 4000))
|
||||
{
|
||||
free(capture);
|
||||
shadow_capture_free(capture);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -27,35 +27,30 @@
|
||||
|
||||
rdpShadowScreen* shadow_screen_new(rdpShadowServer* server)
|
||||
{
|
||||
INT64 x, y;
|
||||
INT64 width, height;
|
||||
rdpShadowScreen* screen;
|
||||
rdpShadowSubsystem* subsystem;
|
||||
MONITOR_DEF* primary;
|
||||
|
||||
WINPR_ASSERT(server);
|
||||
WINPR_ASSERT(server->subsystem);
|
||||
|
||||
screen = (rdpShadowScreen*)calloc(1, sizeof(rdpShadowScreen));
|
||||
rdpShadowScreen* screen = (rdpShadowScreen*)calloc(1, sizeof(rdpShadowScreen));
|
||||
|
||||
if (!screen)
|
||||
goto out_error;
|
||||
goto fail;
|
||||
|
||||
screen->server = server;
|
||||
subsystem = server->subsystem;
|
||||
rdpShadowSubsystem* subsystem = server->subsystem;
|
||||
|
||||
if (!InitializeCriticalSectionAndSpinCount(&(screen->lock), 4000))
|
||||
goto out_free;
|
||||
goto fail;
|
||||
|
||||
region16_init(&(screen->invalidRegion));
|
||||
|
||||
WINPR_ASSERT(subsystem->selectedMonitor < ARRAYSIZE(subsystem->monitors));
|
||||
primary = &(subsystem->monitors[subsystem->selectedMonitor]);
|
||||
const MONITOR_DEF* primary = &(subsystem->monitors[subsystem->selectedMonitor]);
|
||||
WINPR_ASSERT(primary);
|
||||
|
||||
x = primary->left;
|
||||
y = primary->top;
|
||||
width = primary->right - primary->left + 1;
|
||||
height = primary->bottom - primary->top + 1;
|
||||
INT64 x = primary->left;
|
||||
INT64 y = primary->top;
|
||||
INT64 width = primary->right - primary->left + 1;
|
||||
INT64 height = primary->bottom - primary->top + 1;
|
||||
|
||||
WINPR_ASSERT(x >= 0);
|
||||
WINPR_ASSERT(x <= UINT16_MAX);
|
||||
@ -73,30 +68,25 @@ rdpShadowScreen* shadow_screen_new(rdpShadowServer* server)
|
||||
shadow_surface_new(server, (UINT16)x, (UINT16)y, (UINT16)width, (UINT16)height);
|
||||
|
||||
if (!screen->primary)
|
||||
goto out_free_region;
|
||||
goto fail;
|
||||
|
||||
server->surface = screen->primary;
|
||||
|
||||
screen->lobby = shadow_surface_new(server, (UINT16)x, (UINT16)y, (UINT16)width, (UINT16)height);
|
||||
|
||||
if (!screen->lobby)
|
||||
goto out_free_primary;
|
||||
goto fail;
|
||||
|
||||
server->lobby = screen->lobby;
|
||||
|
||||
shadow_client_init_lobby(server);
|
||||
if (!shadow_client_init_lobby(server))
|
||||
goto fail;
|
||||
|
||||
return screen;
|
||||
|
||||
out_free_primary:
|
||||
shadow_surface_free(screen->primary);
|
||||
server->surface = screen->primary = NULL;
|
||||
out_free_region:
|
||||
region16_uninit(&(screen->invalidRegion));
|
||||
DeleteCriticalSection(&(screen->lock));
|
||||
out_free:
|
||||
free(screen);
|
||||
out_error:
|
||||
fail:
|
||||
shadow_screen_free(screen);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user