Skip to content

Commit

Permalink
Merge pull request #31 from william8000/xvjpeg-bug-1sep24
Browse files Browse the repository at this point in the history
xv.c, xvimage.c, xvjpeg.c: Ensure that exifInfo is freed.
  • Loading branch information
mdadams authored Sep 2, 2024
2 parents c72458b + 9c2e7ae commit a1e2dc8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/xv.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ int main(int argc, char **argv)

picComments = (char *) NULL;

if (picExifInfo) free(picExifInfo);
picExifInfo = (byte *) NULL;
picExifInfoSize = 0;

Expand Down Expand Up @@ -2201,6 +2200,7 @@ static int openPic(int filenum)
/* init important fields of pinfo */
pinfo.pic = (byte *) NULL;
pinfo.comment = (char *) NULL;
pinfo.exifInfo = (byte *) NULL;
pinfo.numpages = 1;
pinfo.pagebname[0] = '\0';

Expand Down Expand Up @@ -2652,6 +2652,10 @@ static int openPic(int filenum)
free(pinfo.comment);
}
pinfo.comment = (char *) NULL;
if (pinfo.exifInfo) {
free(pinfo.exifInfo);
}
pinfo.exifInfo = (byte *) NULL;
goto FAILED;
}

Expand Down Expand Up @@ -2703,6 +2707,10 @@ static int openPic(int filenum)
free(pinfo.comment);
}
pinfo.comment = (char *) NULL;
if (pinfo.exifInfo) {
free(pinfo.exifInfo);
}
pinfo.exifInfo = (byte *) NULL;
Warning();
goto FAILED;
}
Expand Down
4 changes: 4 additions & 0 deletions src/xvimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,10 @@ void KillOldPics(void)
if (picComments) free(picComments);
picComments = (char *) NULL;
ChangeCommentText();

if (picExifInfo) free(picExifInfo);
picExifInfo = (byte *) NULL;
picExifInfoSize = 0;
}


Expand Down
14 changes: 9 additions & 5 deletions src/xvjpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ static int writeJFIF PARM((FILE *, byte *, int,int,int));


/*** local variables ***/
static char *filename;
static const char *fbasename;
static char *comment;
static byte *exifInfo;
static int exifInfoSize; /* not a string => must track size explicitly */
static char *filename = NULL;
static const char *fbasename = NULL;
static char *comment = NULL;
static byte *exifInfo = NULL;
static int exifInfoSize = 0; /* not a string => must track size explicitly */
static int colorType;

static DIAL qDial, smDial;
Expand Down Expand Up @@ -518,7 +518,11 @@ int LoadJFIF(char *fname, PICINFO *pinfo, int quick)

fbasename = BaseName(fname);
pic = (byte *) NULL;

if (comment) free(comment);
comment = (char *) NULL;

if (exifInfo) free(exifInfo);
exifInfo = (byte *) NULL;
colorspace_name = "Color";

Expand Down

0 comments on commit a1e2dc8

Please sign in to comment.