[cairo] [PATCH cairo v2 8/8] polygon-intersection: Clarify ptr checks for right edges (CID #1160730)

Bryce Harrington bryce at bryceharrington.org
Wed Jun 13 00:35:38 UTC 2018


The code is checking a variable is non-NULL after it's already been
dereferenced in an assert.

I'm not certain whether the assert should be conditionalized to only be
tested when right != NULL (which would allow edges_end() to still be
invoked), or if the function should assert right as non-NULL always.

Coverity ID: #1160730

Signed-off-by: Bryce Harrington <bryce at bryceharrington.org>
---
 src/cairo-polygon-intersect.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/cairo-polygon-intersect.c b/src/cairo-polygon-intersect.c
index 9c1777f..001e55e 100644
--- a/src/cairo-polygon-intersect.c
+++ b/src/cairo-polygon-intersect.c
@@ -1107,13 +1107,14 @@ edges_start_or_continue (cairo_bo_edge_t	*left,
 			 int			 top,
 			 cairo_polygon_t	*polygon)
 {
+    assert (right != NULL);
     assert (right->deferred.other == NULL);
 
     if (left->deferred.other == right)
 	return;
 
     if (left->deferred.other != NULL) {
-	if (right != NULL && edges_colinear (left->deferred.other, right)) {
+	if (edges_colinear (left->deferred.other, right)) {
 	    cairo_bo_edge_t *old = left->deferred.other;
 
 	    /* continuation on right, extend right to cover both */
@@ -1131,7 +1132,7 @@ edges_start_or_continue (cairo_bo_edge_t	*left,
 	edges_end (left, top, polygon);
     }
 
-    if (right != NULL && ! edges_colinear (left, right)) {
+    if (! edges_colinear (left, right)) {
 	left->deferred.top = top;
 	left->deferred.other = right;
     }
-- 
2.7.4



More information about the cairo mailing list