sna/video: Don't assert on a client error, return BadAlloc

If the client sends a BO that is too small to satifsy the PutImage, then
reject with BadAlloc rather than die with an assert.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-08-16 15:38:18 +01:00
parent cb35a0b19a
commit 7a6bd55da9
3 changed files with 21 additions and 3 deletions

View File

@ -523,7 +523,13 @@ sna_video_overlay_put_image(ClientPtr client,
return BadAlloc;
}
assert(kgem_bo_size(frame.bo) >= frame.size);
if (kgem_bo_size(frame.bo) < frame.size) {
DBG(("%s: bo size=%d, expected=%d\n",
__FUNCTION__, kgem_bo_size(frame.bo), frame.size));
kgem_bo_destroy(&sna->kgem, frame.bo);
return BadAlloc;
}
frame.image.x1 = 0;
frame.image.y1 = 0;
frame.image.x2 = frame.width;

View File

@ -348,7 +348,13 @@ static int sna_video_sprite_put_image(ClientPtr client,
if (frame.bo == NULL)
return BadAlloc;
assert(kgem_bo_size(frame.bo) >= frame.size);
if (kgem_bo_size(frame.bo) < frame.size) {
DBG(("%s: bo size=%d, expected=%d\n",
__FUNCTION__, kgem_bo_size(frame.bo), frame.size));
kgem_bo_destroy(&sna->kgem, frame.bo);
return BadAlloc;
}
frame.image.x1 = 0;
frame.image.y1 = 0;
frame.image.x2 = frame.width;

View File

@ -222,7 +222,13 @@ sna_video_textured_put_image(ClientPtr client,
return BadAlloc;
}
assert(kgem_bo_size(frame.bo) >= frame.size);
if (kgem_bo_size(frame.bo) < frame.size) {
DBG(("%s: bo size=%d, expected=%d\n",
__FUNCTION__, kgem_bo_size(frame.bo), frame.size));
kgem_bo_destroy(&sna->kgem, frame.bo);
return BadAlloc;
}
frame.image.x1 = 0;
frame.image.y1 = 0;
frame.image.x2 = frame.width;