Skip to content

Commit dc6dcc0

Browse files
authored
fix: dangling pointer in transform mat
1 parent 2c4ca88 commit dc6dcc0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

native/src/context2d.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ sk_context_state* clone_context_state(sk_context_state* state) {
5454
new_state->globalAlpha = state->globalAlpha;
5555
new_state->lineDashOffset = state->lineDashOffset;
5656
new_state->fillStyle = state->fillStyle;
57-
// if (new_state->fillStyle.shader) new_state->fillStyle.shader = sk_sp(new_state->fillStyle.shader);
57+
if (new_state->fillStyle.shader) new_state->fillStyle.shader = sk_sp(new_state->fillStyle.shader);
5858
new_state->strokeStyle = state->strokeStyle;
59-
// if (new_state->strokeStyle.shader) new_state->strokeStyle.shader = sk_sp(new_state->strokeStyle.shader);
59+
if (new_state->strokeStyle.shader) new_state->strokeStyle.shader = sk_sp(new_state->strokeStyle.shader);
6060
new_state->shadowColor = state->shadowColor;
6161
new_state->transform = new SkMatrix(*state->transform);
6262
new_state->imageSmoothingEnabled = state->imageSmoothingEnabled;
@@ -493,7 +493,6 @@ extern "C" {
493493

494494
// Context.lineCap setter
495495
void sk_context_set_line_cap(sk_context* context, int cap) {
496-
// std::cout << "setLineCap: " << context->state->paint << std::endl;
497496
switch (cap) {
498497
case 0:
499498
context->state->paint->setStrokeCap(SkPaint::kButt_Cap);
@@ -576,7 +575,7 @@ extern "C" {
576575
int variant,
577576
int stretch
578577
) {
579-
// free(context->state->font);
578+
free(context->state->font);
580579
context->state->font = new Font();
581580
context->state->font->family = strdup(family);
582581
context->state->font->size = size;
@@ -940,7 +939,6 @@ extern "C" {
940939
ts->setAll(a, b, e, c, d, f, 0.0f, 0.0f, 1.0f);
941940
s->transform = ts;
942941
context->canvas->setMatrix(*s->transform);
943-
// delete ts;
944942
}
945943

946944
// Context.resetTransform()
@@ -1294,7 +1292,7 @@ extern "C" {
12941292
delete context->state;
12951293
for (auto state : context->states) {
12961294
free_context_state(state);
1297-
// delete state;
1295+
delete state;
12981296
}
12991297
delete context;
13001298
}

0 commit comments

Comments
 (0)