diff --git a/CHANGELOG.md b/CHANGELOG.md index b3ba9a13b..b00be0b9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ project adheres to [Semantic Versioning](http://semver.org/). * Migrate from librsvg's deprecated `rsvg_handle_get_dimensions()` and `rsvg_handle_render_cairo()` functions to the new `rsvg_handle_get_intrinsic_size_in_pixels()` and `rsvg_handle_render_document()` respectively. (#2229) * Avoid calling virtual methods in constructors/destructors to avoid bypassing virtual dispatch. (#2229) * Remove unused private field `backend` in the `Backend` class. (#2229) +* Migrated to N-API (by way of node-addon-api) and removed libuv and v8 dependencies ### Added * Added string tags to support class detection ### Fixed diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index 0bbdf5eda..e1fb4b94d 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -2138,8 +2138,11 @@ Context2d::_setFillColor(Napi::Value arg) { short ok; if (stringValue.IsJust()) { - std::string str = stringValue.Unwrap().Utf8Value(); - uint32_t rgba = rgba_from_string(str.c_str(), &ok); + Napi::String str = stringValue.Unwrap(); + char buf[128] = {0}; + napi_status status = napi_get_value_string_utf8(env, str, buf, sizeof(buf) - 1, nullptr); + if (status != napi_ok) return; + uint32_t rgba = rgba_from_string(buf, &ok); if (!ok) return; state->fillPattern = state->fillGradient = NULL; state->fill = rgba_create(rgba);