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

Marc-André Lureau marcandre.lureau at gmail.com
Fri Oct 24 06:10:29 PDT 2014


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



More information about the Spice-devel mailing list