Commit 7767103e authored by Florian Müllner's avatar Florian Müllner

cairo-context: Fix handling of empty arrays

gcc's libstdc++ enables stricter checks when code is compiled with
_GLIBCXX_ASSERTIONS, including bound checks for std::vector's []
operator.

We currently hit this assertion when setDash() is called with an
empty array (which is legal with regard to the underlying cairo
API). Fix by using the dedicated vector method to access the
underlying data.

https://gitlab.gnome.org/GNOME/gjs/merge_requests/271
parent 5eb80e2d
......@@ -137,6 +137,8 @@ describe('Cairo', function () {
cr.paint();
cr.paintWithAlpha(1);
cr.setDash([1, 0.5], 1);
cr.stroke();
cr.strokePreserve();
......@@ -153,7 +155,7 @@ describe('Cairo', function () {
cr.showText("foobar");
cr.moveTo(0, 0);
cr.setDash([1, 0.5], 1);
cr.setDash([], 1);
cr.lineTo(1, 0);
cr.lineTo(1, 1);
cr.lineTo(0, 1);
......
......@@ -588,7 +588,7 @@ setDash_func(JSContext *context,
dashes_c.push_back(b);
}
cairo_set_dash(cr, &dashes_c[0], dashes_c.size(), offset);
cairo_set_dash(cr, dashes_c.data(), dashes_c.size(), offset);
argv.rval().setUndefined();
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment