Skip to content

Commit

Permalink
Destroy image on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 5, 2025
1 parent fa07824 commit 348e6cd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/_avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
image->yuvRange = AVIF_RANGE_LIMITED;
} else {
PyErr_SetString(PyExc_ValueError, "Invalid range");
avifImageDestroy(image);
return NULL;
}
if (strcmp(subsampling, "4:0:0") == 0) {
Expand All @@ -301,6 +302,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
image->yuvFormat = AVIF_PIXEL_FORMAT_YUV444;
} else {
PyErr_Format(PyExc_ValueError, "Invalid subsampling: %s", subsampling);
avifImageDestroy(image);
return NULL;
}

Expand Down

0 comments on commit 348e6cd

Please sign in to comment.