Skip to content

Commit 84ed0bc

Browse files
committed
Fix a memory leak problem in encoder caused by bad reference counting
1 parent f94bc6f commit 84ed0bc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/encoder.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ sixel_parse_x_colorspec(
225225
}
226226

227227
status = SIXEL_OK;
228+
228229
end:
229230
sixel_allocator_free(allocator, buf);
230231

@@ -1155,10 +1156,7 @@ sixel_encoder_new(
11551156
env_default_bgcolor,
11561157
allocator);
11571158
if (SIXEL_FAILED(status)) {
1158-
sixel_allocator_free(allocator, *ppencoder);
1159-
sixel_allocator_unref(allocator);
1160-
*ppencoder = NULL;
1161-
goto end;
1159+
goto error;
11621160
}
11631161
}
11641162

@@ -1171,11 +1169,16 @@ sixel_encoder_new(
11711169
}
11721170
}
11731171

1174-
sixel_allocator_ref(allocator);
1175-
11761172
/* success */
11771173
status = SIXEL_OK;
11781174

1175+
goto end;
1176+
1177+
error:
1178+
sixel_allocator_free(allocator, *ppencoder);
1179+
sixel_allocator_unref(allocator);
1180+
*ppencoder = NULL;
1181+
11791182
end:
11801183
return status;
11811184
}

0 commit comments

Comments
 (0)