[Spice-devel] [PATCH spice] Validate RedDrawable bbox before allocating drawable

2014-10-24 Thread Marc-André Lureau
Avoid unnecessary allocation (and possibly leaking) if the RedDrawable
doesn't validate_drawable_bbox()

Related to: rhbz#1135372
---
 server/red_worker.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index e177b68..d56db35 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -4068,6 +4068,11 @@ static Drawable *get_drawable(RedWorker *worker, uint8_t 
effect, RedDrawable *re
 struct timespec time;
 int x;
 
+if (!validate_drawable_bbox(worker, red_drawable)) {
+rendering_incorrect(__func__);
+return NULL;
+}
+
 while (!(drawable = alloc_drawable(worker))) {
 free_one_drawable(worker, FALSE);
 }
@@ -4100,10 +4105,6 @@ static Drawable *get_drawable(RedWorker *worker, uint8_t 
effect, RedDrawable *re
 VALIDATE_SURFACE_RETVAL(worker, drawable-surfaces_dest[x], NULL)
 }
 }
-if (!validate_drawable_bbox(worker, red_drawable)) {
-rendering_incorrect(__func__);
-return NULL;
-}
 ring_init(drawable-pipes);
 ring_init(drawable-glz_ring);
 
-- 
1.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice] Validate RedDrawable bbox before allocating drawable

2014-10-24 Thread Christophe Fergeau
Hey,

On Fri, Oct 24, 2014 at 03:10:29PM +0200, Marc-André Lureau wrote:
 Avoid unnecessary allocation (and possibly leaking) if the RedDrawable
 doesn't validate_drawable_bbox()
 
 Related to: rhbz#1135372
 ---
  server/red_worker.c | 9 +
  1 file changed, 5 insertions(+), 4 deletions(-)
 
 diff --git a/server/red_worker.c b/server/red_worker.c
 index e177b68..d56db35 100644
 --- a/server/red_worker.c
 +++ b/server/red_worker.c
 @@ -4068,6 +4068,11 @@ static Drawable *get_drawable(RedWorker *worker, 
 uint8_t effect, RedDrawable *re
  struct timespec time;
  int x;
  

You'll need to move the
VALIDATE_SURFACE_RETVAL(worker, drawable-surface_id, NULL);
check before calling  validate_drawable_bbox() (or into that call).

 +if (!validate_drawable_bbox(worker, red_drawable)) {
 +rendering_incorrect(__func__);
 +return NULL;
 +}
 +


Christophe


pgpqzfb4JJAzL.pgp
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel