Xext: xvmc: skip reply payload assembly when no data to send

Instead of trying to calloc() zero-size blocks when there's no actual payload
to send, skip the whole part. This also helps reducing analyzer noise.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-05-15 11:41:17 +02:00
parent e03b163b9b
commit ec4443f070

View File

@ -149,8 +149,10 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
} }
int num_surfaces = (adaptor) ? adaptor->num_surfaces : 0; int num_surfaces = (adaptor) ? adaptor->num_surfaces : 0;
xvmcSurfaceInfo *info = calloc(sizeof(xvmcSurfaceInfo), num_surfaces); xvmcSurfaceInfo *info = NULL;
if (!info && num_surfaces) if (num_surfaces) {
info = calloc(sizeof(xvmcSurfaceInfo), num_surfaces);
if (!info)
return BadAlloc; return BadAlloc;
for (int i = 0; i < num_surfaces; i++) { for (int i = 0; i < num_surfaces; i++) {
@ -164,6 +166,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
info[i].mc_type = surface->mc_type; info[i].mc_type = surface->mc_type;
info[i].flags = surface->flags; info[i].flags = surface->flags;
} }
}
xvmcListSurfaceTypesReply rep = { xvmcListSurfaceTypesReply rep = {
.type = X_Reply, .type = X_Reply,
@ -542,8 +545,10 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
int num = (surface->compatible_subpictures ? int num = (surface->compatible_subpictures ?
surface->compatible_subpictures->num_xvimages : 0); surface->compatible_subpictures->num_xvimages : 0);
xvImageFormatInfo *info = calloc(sizeof(xvImageFormatInfo), num); xvImageFormatInfo *info = NULL;
if (!info && num) if (num) {
info = calloc(sizeof(xvImageFormatInfo), num);
if (!info)
return BadAlloc; return BadAlloc;
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
@ -583,6 +588,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
memcpy(&info[i].comp_order, pImage->component_order, 32); memcpy(&info[i].comp_order, pImage->component_order, 32);
info[i].scanline_order = pImage->scanline_order; info[i].scanline_order = pImage->scanline_order;
} }
}
xvmcListSubpictureTypesReply rep = { xvmcListSubpictureTypesReply rep = {
.type = X_Reply, .type = X_Reply,