Skip to content

Commit a1e2dc8

Browse files
authored
Merge pull request #31 from william8000/xvjpeg-bug-1sep24
xv.c, xvimage.c, xvjpeg.c: Ensure that exifInfo is freed.
2 parents c72458b + 9c2e7ae commit a1e2dc8

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

src/xv.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ int main(int argc, char **argv)
214214

215215
picComments = (char *) NULL;
216216

217-
if (picExifInfo) free(picExifInfo);
218217
picExifInfo = (byte *) NULL;
219218
picExifInfoSize = 0;
220219

@@ -2201,6 +2200,7 @@ static int openPic(int filenum)
22012200
/* init important fields of pinfo */
22022201
pinfo.pic = (byte *) NULL;
22032202
pinfo.comment = (char *) NULL;
2203+
pinfo.exifInfo = (byte *) NULL;
22042204
pinfo.numpages = 1;
22052205
pinfo.pagebname[0] = '\0';
22062206

@@ -2652,6 +2652,10 @@ static int openPic(int filenum)
26522652
free(pinfo.comment);
26532653
}
26542654
pinfo.comment = (char *) NULL;
2655+
if (pinfo.exifInfo) {
2656+
free(pinfo.exifInfo);
2657+
}
2658+
pinfo.exifInfo = (byte *) NULL;
26552659
goto FAILED;
26562660
}
26572661

@@ -2703,6 +2707,10 @@ static int openPic(int filenum)
27032707
free(pinfo.comment);
27042708
}
27052709
pinfo.comment = (char *) NULL;
2710+
if (pinfo.exifInfo) {
2711+
free(pinfo.exifInfo);
2712+
}
2713+
pinfo.exifInfo = (byte *) NULL;
27062714
Warning();
27072715
goto FAILED;
27082716
}

src/xvimage.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,10 @@ void KillOldPics(void)
14481448
if (picComments) free(picComments);
14491449
picComments = (char *) NULL;
14501450
ChangeCommentText();
1451+
1452+
if (picExifInfo) free(picExifInfo);
1453+
picExifInfo = (byte *) NULL;
1454+
picExifInfoSize = 0;
14511455
}
14521456

14531457

src/xvjpeg.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ static int writeJFIF PARM((FILE *, byte *, int,int,int));
7777

7878

7979
/*** local variables ***/
80-
static char *filename;
81-
static const char *fbasename;
82-
static char *comment;
83-
static byte *exifInfo;
84-
static int exifInfoSize; /* not a string => must track size explicitly */
80+
static char *filename = NULL;
81+
static const char *fbasename = NULL;
82+
static char *comment = NULL;
83+
static byte *exifInfo = NULL;
84+
static int exifInfoSize = 0; /* not a string => must track size explicitly */
8585
static int colorType;
8686

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

519519
fbasename = BaseName(fname);
520520
pic = (byte *) NULL;
521+
522+
if (comment) free(comment);
521523
comment = (char *) NULL;
524+
525+
if (exifInfo) free(exifInfo);
522526
exifInfo = (byte *) NULL;
523527
colorspace_name = "Color";
524528

0 commit comments

Comments
 (0)