Skip to content

Commit

Permalink
Merge pull request #3 from radarhere/write-jpeg-com
Browse files Browse the repository at this point in the history
Free comment when returning early
  • Loading branch information
smason committed Dec 6, 2022
2 parents eddc9bd + 1d78008 commit 6ca08a4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/encode.c
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 6ca08a4

Please sign in to comment.