diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-16 15:38:18 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-16 15:39:30 +0100 |
commit | 7a6bd55da90382459db072bffbd4aa36d18f9a17 (patch) | |
tree | 97a1072f77b3b09edb8168be2d4ff5f5ddb39f88 /src | |
parent | cb35a0b19a4a1c9ac4e2bb552a61057c215ce890 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna_video_overlay.c | 8 | ||||
-rw-r--r-- | src/sna/sna_video_sprite.c | 8 | ||||
-rw-r--r-- | src/sna/sna_video_textured.c | 8 |
3 files changed, 21 insertions, 3 deletions
diff --git a/src/sna/sna_video_overlay.c b/src/sna/sna_video_overlay.c index a68a173b..cfdc83d6 100644 --- a/src/sna/sna_video_overlay.c +++ b/src/sna/sna_video_overlay.c @@ -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; diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index a8d50ab2..cab2cdaa 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -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; diff --git a/src/sna/sna_video_textured.c b/src/sna/sna_video_textured.c index d3ce2804..7ec17d18 100644 --- a/src/sna/sna_video_textured.c +++ b/src/sna/sna_video_textured.c @@ -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; |