[gjs: 1/2] cairo-context: Fix handling of empty arrays
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 1/2] cairo-context: Fix handling of empty arrays
- Date: Sat, 2 Mar 2019 20:06:46 +0000 (UTC)
commit 7767103e89e20726b6fac4d300f219205f9083cd
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Feb 22 14:16:17 2019 +0100
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
installed-tests/js/testCairo.js | 4 +++-
modules/cairo-context.cpp | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/installed-tests/js/testCairo.js b/installed-tests/js/testCairo.js
index db20de0f..4905ae92 100644
--- a/installed-tests/js/testCairo.js
+++ b/installed-tests/js/testCairo.js
@@ -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);
diff --git a/modules/cairo-context.cpp b/modules/cairo-context.cpp
index 7a3168b9..738b9401 100644
--- a/modules/cairo-context.cpp
+++ b/modules/cairo-context.cpp
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]