Skip to content

Commit

Permalink
Fix a memory leak problem in encoder caused by bad reference counting
Browse files Browse the repository at this point in the history
  • Loading branch information
saitoha committed Jul 22, 2018
1 parent f94bc6f commit 84ed0bc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/encoder.c
Expand Up @@ -225,6 +225,7 @@ sixel_parse_x_colorspec(
}

status = SIXEL_OK;

end:
sixel_allocator_free(allocator, buf);

Expand Down Expand Up @@ -1155,10 +1156,7 @@ sixel_encoder_new(
env_default_bgcolor,
allocator);
if (SIXEL_FAILED(status)) {
sixel_allocator_free(allocator, *ppencoder);
sixel_allocator_unref(allocator);
*ppencoder = NULL;
goto end;
goto error;
}
}

Expand All @@ -1171,11 +1169,16 @@ sixel_encoder_new(
}
}

sixel_allocator_ref(allocator);

/* success */
status = SIXEL_OK;

goto end;

error:
sixel_allocator_free(allocator, *ppencoder);
sixel_allocator_unref(allocator);
*ppencoder = NULL;

end:
return status;
}
Expand Down

0 comments on commit 84ed0bc

Please sign in to comment.