(submit/cleanup-xv-dispatch) Xext: xv: use alloca() for small buffer in ProcXvQueryImageAttributes()

The buffer should be small enough for easily fitting on stack, so let's
use that and never again worrying about forgotten free()'s :)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2024-07-10 18:41:17 +02:00
parent 3fb604fd28
commit edb8484c2c

View File

@@ -995,7 +995,7 @@ ProcXvQueryImageAttributes(ClientPtr client)
// allocating for `offsets` as well as `pitches` in one block
// both having CARD32 * num_planes (actually int32_t put into CARD32)
if (!(offsets = malloc(num_planes * sizeof(CARD32) * 2)))
if (!(offsets = alloca(num_planes * sizeof(CARD32) * 2)))
return BadAlloc;
pitches = offsets + num_planes;
@@ -1021,8 +1021,6 @@ ProcXvQueryImageAttributes(ClientPtr client)
SwapLongs((CARD32 *) offsets, rep.length);
WriteToClient(client, rep.length * sizeof(CARD32), offsets);
free(offsets);
return Success;
}