Skip to content

Commit

Permalink
Free comment when returning early
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 6, 2022
1 parent eddc9bd commit 1d78008
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,9 @@ PyImaging_JpegEncoderNew(PyObject *self, PyObject *args) {
/* malloc check ok, length is from python parsearg */
char *p = malloc(extra_size); // Freed in JpegEncode, Case 6
if (!p) {
if (comment) {
free(comment);
}
return ImagingError_MemoryError();
}
memcpy(p, extra, extra_size);
Expand All @@ -1125,6 +1128,9 @@ PyImaging_JpegEncoderNew(PyObject *self, PyObject *args) {
/* malloc check ok, length is from python parsearg */
char *pp = malloc(rawExifLen); // Freed in JpegEncode, Case 6
if (!pp) {
if (comment) {
free(comment);
}
if (extra) {
free(extra);
}
Expand Down

0 comments on commit 1d78008

Please sign in to comment.