xserver: Branch 'master' - 3 commits

Adam Jackson ajax at kemper.freedesktop.org
Wed Mar 15 20:09:33 UTC 2017


 glamor/glamor_copy.c      |   17 ++++++++++-------
 glamor/glamor_glyphblt.c  |   26 ++++++++++++++++----------
 glamor/glamor_lines.c     |   13 ++++++++-----
 glamor/glamor_points.c    |   14 ++++++++------
 glamor/glamor_rects.c     |   13 ++++++++-----
 glamor/glamor_segs.c      |   14 ++++++++------
 glamor/glamor_spans.c     |   13 ++++++++-----
 glamor/glamor_transform.c |   11 +++++++++--
 glamor/glamor_transform.h |    2 +-
 hw/xfree86/parser/scan.c  |    2 ++
 10 files changed, 78 insertions(+), 47 deletions(-)

New commits:
commit f1f865e909090406841a9b9416ea6259a75c2086
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Jan 23 11:31:36 2017 -0500

    parser: Fix crash when xf86nameCompare(s1 = x, s2 = NULL)
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 81a454b..3356224 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -1046,6 +1046,8 @@ xf86nameCompare(const char *s1, const char *s2)
             return 0;
         else
             return 1;
+    } else if (!s2 || *s2 == 0) {
+        return -1;
     }
 
     while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
commit 455051a0f1d2bc84f605c325f647bd64d414c47d
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 14 15:06:34 2017 +0100

    glamor: Check glamor_set_destination_drawable() return value
    
    Check the value returned by glamor_set_destination_drawable() and use
    the fallback code path where possible.
    
    Bugzilla: https://bugzilla.redhat.com/1417575
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>

diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index 3ca56fb..ff8f44e 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -344,6 +344,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
     glamor_program *prog;
     const glamor_facet *copy_facet;
     int n;
+    Bool ret = FALSE;
 
     glamor_make_current(glamor_priv);
 
@@ -410,9 +411,10 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
             goto bail_ctx;
 
         glamor_pixmap_loop(dst_priv, dst_box_index) {
-            glamor_set_destination_drawable(dst, dst_box_index, FALSE, FALSE,
-                                            prog->matrix_uniform,
-                                            &dst_off_x, &dst_off_y);
+            if (!glamor_set_destination_drawable(dst, dst_box_index, FALSE, FALSE,
+                                                 prog->matrix_uniform,
+                                                 &dst_off_x, &dst_off_y))
+                goto bail_ctx;
 
             glScissor(dst_off_x - args.dx,
                       dst_off_y - args.dy,
@@ -422,13 +424,14 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
             glamor_glDrawArrays_GL_QUADS(glamor_priv, nbox);
         }
     }
-    glDisable(GL_SCISSOR_TEST);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
 
-    return TRUE;
+    ret = TRUE;
 
 bail_ctx:
-    return FALSE;
+    glDisable(GL_SCISSOR_TEST);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+
+    return ret;
 }
 
 /**
diff --git a/glamor/glamor_glyphblt.c b/glamor/glamor_glyphblt.c
index b21aa06..78315ea 100644
--- a/glamor/glamor_glyphblt.c
+++ b/glamor/glamor_glyphblt.c
@@ -49,6 +49,7 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
     glamor_program *prog;
     RegionPtr clip = gc->pCompositeClip;
     int box_index;
+    Bool ret = FALSE;
 
     pixmap_priv = glamor_get_pixmap_private(pixmap);
     if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
@@ -75,8 +76,9 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
         int off_x, off_y;
         char *vbo_offset;
 
-        glamor_set_destination_drawable(drawable, box_index, FALSE, TRUE,
-                                        prog->matrix_uniform, &off_x, &off_y);
+        if (!glamor_set_destination_drawable(drawable, box_index, FALSE, TRUE,
+                                              prog->matrix_uniform, &off_x, &off_y))
+            goto bail;
 
         max_points = 500;
         num_points = 0;
@@ -138,11 +140,12 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
         }
     }
 
-    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    ret = TRUE;
 
-    return TRUE;
 bail:
-    return FALSE;
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+
+    return ret;
 }
 
 void
@@ -174,6 +177,7 @@ glamor_push_pixels_gl(GCPtr gc, PixmapPtr bitmap,
     int num_points;
     INT16 *points = NULL;
     char *vbo_offset;
+    Bool ret = FALSE;
 
     if (w * h > MAXINT / (2 * sizeof(float)))
         goto bail;
@@ -221,17 +225,19 @@ glamor_push_pixels_gl(GCPtr gc, PixmapPtr bitmap,
     glamor_put_vbo_space(screen);
 
     glamor_pixmap_loop(pixmap_priv, box_index) {
-        glamor_set_destination_drawable(drawable, box_index, FALSE, TRUE,
-                                        prog->matrix_uniform, NULL, NULL);
+        if (!glamor_set_destination_drawable(drawable, box_index, FALSE, TRUE,
+                                             prog->matrix_uniform, NULL, NULL))
+            goto bail;
 
         glDrawArrays(GL_POINTS, 0, num_points);
     }
 
-    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    return TRUE;
+    ret = TRUE;
 
 bail:
-    return FALSE;
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+
+    return ret;
 }
 
 void
diff --git a/glamor/glamor_lines.c b/glamor/glamor_lines.c
index a2c9b1f..5d95333 100644
--- a/glamor/glamor_lines.c
+++ b/glamor/glamor_lines.c
@@ -46,6 +46,7 @@ glamor_poly_lines_solid_gl(DrawablePtr drawable, GCPtr gc,
     char *vbo_offset;
     int box_index;
     int add_last;
+    Bool ret = FALSE;
 
     pixmap_priv = glamor_get_pixmap_private(pixmap);
     if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
@@ -103,8 +104,9 @@ glamor_poly_lines_solid_gl(DrawablePtr drawable, GCPtr gc,
         int nbox = RegionNumRects(gc->pCompositeClip);
         BoxPtr box = RegionRects(gc->pCompositeClip);
 
-        glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
-                                        prog->matrix_uniform, &off_x, &off_y);
+        if (!glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
+                                             prog->matrix_uniform, &off_x, &off_y))
+            goto bail;
 
         while (nbox--) {
             glScissor(box->x1 + off_x,
@@ -116,12 +118,13 @@ glamor_poly_lines_solid_gl(DrawablePtr drawable, GCPtr gc,
         }
     }
 
+    ret = TRUE;
+
+bail:
     glDisable(GL_SCISSOR_TEST);
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
 
-    return TRUE;
-bail:
-    return FALSE;
+    return ret;
 }
 
 static Bool
diff --git a/glamor/glamor_points.c b/glamor/glamor_points.c
index facfe82..faf6f43 100644
--- a/glamor/glamor_points.c
+++ b/glamor/glamor_points.c
@@ -47,6 +47,7 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
     GLshort *vbo_ppt;
     char *vbo_offset;
     int box_index;
+    Bool ret = FALSE;
 
     pixmap_priv = glamor_get_pixmap_private(pixmap);
     if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
@@ -90,8 +91,9 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
         int nbox = RegionNumRects(gc->pCompositeClip);
         BoxPtr box = RegionRects(gc->pCompositeClip);
 
-        glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
-                                        prog->matrix_uniform, &off_x, &off_y);
+        if (!glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
+                                             prog->matrix_uniform, &off_x, &off_y))
+            goto bail;
 
         while (nbox--) {
             glScissor(box->x1 + off_x,
@@ -103,13 +105,13 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
         }
     }
 
+    ret = TRUE;
+
+bail:
     glDisable(GL_SCISSOR_TEST);
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
 
-    return TRUE;
-
-bail:
-    return FALSE;
+    return ret;
 }
 
 void
diff --git a/glamor/glamor_rects.c b/glamor/glamor_rects.c
index e447320..cc029c8 100644
--- a/glamor/glamor_rects.c
+++ b/glamor/glamor_rects.c
@@ -52,6 +52,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
     GLshort *v;
     char *vbo_offset;
     int box_index;
+    Bool ret = FALSE;
 
     pixmap_priv = glamor_get_pixmap_private(pixmap);
     if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
@@ -115,8 +116,9 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
         int nbox = RegionNumRects(gc->pCompositeClip);
         BoxPtr box = RegionRects(gc->pCompositeClip);
 
-        glamor_set_destination_drawable(drawable, box_index, TRUE, FALSE,
-                                        prog->matrix_uniform, &off_x, &off_y);
+        if (!glamor_set_destination_drawable(drawable, box_index, TRUE, FALSE,
+                                             prog->matrix_uniform, &off_x, &off_y))
+            goto bail;
 
         while (nbox--) {
             glScissor(box->x1 + off_x,
@@ -132,14 +134,15 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
         }
     }
 
+    ret = TRUE;
+
+bail:
     glDisable(GL_SCISSOR_TEST);
     if (glamor_priv->glsl_version >= 130)
         glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
 
-    return TRUE;
-bail:
-    return FALSE;
+    return ret;
 }
 
 static void
diff --git a/glamor/glamor_segs.c b/glamor/glamor_segs.c
index 5fffa3b..4dfa655 100644
--- a/glamor/glamor_segs.c
+++ b/glamor/glamor_segs.c
@@ -46,6 +46,7 @@ glamor_poly_segment_solid_gl(DrawablePtr drawable, GCPtr gc,
     char *vbo_offset;
     int box_index;
     int add_last;
+    Bool ret = FALSE;
 
     pixmap_priv = glamor_get_pixmap_private(pixmap);
     if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
@@ -62,7 +63,7 @@ glamor_poly_segment_solid_gl(DrawablePtr drawable, GCPtr gc,
                                    &glamor_facet_poly_segment);
 
     if (!prog)
-        goto bail_ctx;
+        goto bail;
 
     /* Set up the vertex buffers for the points */
 
@@ -95,8 +96,9 @@ glamor_poly_segment_solid_gl(DrawablePtr drawable, GCPtr gc,
         int nbox = RegionNumRects(gc->pCompositeClip);
         BoxPtr box = RegionRects(gc->pCompositeClip);
 
-        glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
-                                        prog->matrix_uniform, &off_x, &off_y);
+        if (!glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE,
+                                             prog->matrix_uniform, &off_x, &off_y))
+            goto bail;
 
         while (nbox--) {
             glScissor(box->x1 + off_x,
@@ -108,13 +110,13 @@ glamor_poly_segment_solid_gl(DrawablePtr drawable, GCPtr gc,
         }
     }
 
+    ret = TRUE;
+
     glDisable(GL_SCISSOR_TEST);
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
 
-    return TRUE;
-bail_ctx:
 bail:
-    return FALSE;
+    return ret;
 }
 
 static Bool
diff --git a/glamor/glamor_spans.c b/glamor/glamor_spans.c
index 9a2aecd..b3c028d 100644
--- a/glamor/glamor_spans.c
+++ b/glamor/glamor_spans.c
@@ -56,6 +56,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
     char *vbo_offset;
     int c;
     int box_index;
+    Bool ret = FALSE;
 
     pixmap_priv = glamor_get_pixmap_private(pixmap);
     if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
@@ -123,8 +124,9 @@ glamor_fill_spans_gl(DrawablePtr drawable,
         int nbox = RegionNumRects(gc->pCompositeClip);
         BoxPtr box = RegionRects(gc->pCompositeClip);
 
-        glamor_set_destination_drawable(drawable, box_index, FALSE, FALSE,
-                                        prog->matrix_uniform, &off_x, &off_y);
+        if (!glamor_set_destination_drawable(drawable, box_index, FALSE, FALSE,
+                                             prog->matrix_uniform, &off_x, &off_y))
+            goto bail;
 
         while (nbox--) {
             glScissor(box->x1 + off_x,
@@ -140,14 +142,15 @@ glamor_fill_spans_gl(DrawablePtr drawable,
         }
     }
 
+    ret = TRUE;
+
+bail:
     glDisable(GL_SCISSOR_TEST);
     if (glamor_priv->glsl_version >= 130)
         glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
 
-    return TRUE;
-bail:
-    return FALSE;
+    return ret;
 }
 
 static void
commit 04b4bad7c048fd077fe839f10634c99ef1e488af
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 14 14:58:26 2017 +0100

    glamor: glamor_set_destination_drawable() can fail
    
    The fbo_array of a given glamor pixmap can be NULL in some cases, as
    glamor_create_fbo_array() can fail to allocate the FBO array.
    
    If this is the case, glamor_pixmap_fbo_at() will return NULL even though
    the box index is valid, and glamor_set_destination_drawable() simply
    assumes glamor_pixmap_fbo_at() will return an FBO prior to pass the
    value to glamor_set_destination_pixmap_fbo(), which will segfault.
    
    We need a way for glamor_set_destination_drawable() to fail safely and
    let the caller know about the failure.
    
    Add a boolean return value to glamor_set_destination_drawable() for that
    purpose.
    
    Bugzilla: https://bugzilla.redhat.com/1417575
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>

diff --git a/glamor/glamor_transform.c b/glamor/glamor_transform.c
index eff500c..2d5a634 100644
--- a/glamor/glamor_transform.c
+++ b/glamor/glamor_transform.c
@@ -33,7 +33,7 @@
  * clipping computations can be adjusted as appropriate
  */
 
-void
+Bool
 glamor_set_destination_drawable(DrawablePtr     drawable,
                                 int             box_index,
                                 Bool            do_drawable_translate,
@@ -53,6 +53,11 @@ glamor_set_destination_drawable(DrawablePtr     drawable,
     float scale_x = 2.0f / (float) w;
     float scale_y = 2.0f / (float) h;
     float center_adjust = 0.0f;
+    glamor_pixmap_fbo *pixmap_fbo;
+
+    pixmap_fbo = glamor_pixmap_fbo_at(pixmap_priv, box_index);
+    if (!pixmap_fbo)
+        return FALSE;
 
     glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
 
@@ -94,8 +99,10 @@ glamor_set_destination_drawable(DrawablePtr     drawable,
                 scale_x, (off_x + center_adjust) * scale_x - 1.0f,
                 scale_y, (off_y + center_adjust) * scale_y - 1.0f);
 
-    glamor_set_destination_pixmap_fbo(glamor_priv, glamor_pixmap_fbo_at(pixmap_priv, box_index),
+    glamor_set_destination_pixmap_fbo(glamor_priv, pixmap_fbo,
                                       0, 0, w, h);
+
+    return TRUE;
 }
 
 /*
diff --git a/glamor/glamor_transform.h b/glamor/glamor_transform.h
index 70d2c16..28855e3 100644
--- a/glamor/glamor_transform.h
+++ b/glamor/glamor_transform.h
@@ -23,7 +23,7 @@
 #ifndef _GLAMOR_TRANSFORM_H_
 #define _GLAMOR_TRANSFORM_H_
 
-void
+Bool
 glamor_set_destination_drawable(DrawablePtr     drawable,
                                 int             box_index,
                                 Bool            do_drawable_translate,


More information about the xorg-commit mailing list