diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2022-12-24 00:10:51 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2022-12-24 00:10:51 +0000 |
commit | 392e4536f1071ca8de7d81224adf62d11733445b (patch) | |
tree | 7ff0041cbc6f172775efefc26276f91f44992f0c | |
parent | 9a8f829dce63edd0a657d20f3ecb845f9be25cc9 (diff) | |
download | netpbm-mirror-392e4536f1071ca8de7d81224adf62d11733445b.tar.gz netpbm-mirror-392e4536f1071ca8de7d81224adf62d11733445b.tar.xz netpbm-mirror-392e4536f1071ca8de7d81224adf62d11733445b.zip |
Fix free of automatic variable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4481 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | converter/ppm/ppmtompeg/frame.c | 2 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/readframe.c | 43 | ||||
-rw-r--r-- | doc/HISTORY | 3 |
3 files changed, 26 insertions, 22 deletions
diff --git a/converter/ppm/ppmtompeg/frame.c b/converter/ppm/ppmtompeg/frame.c index 05cf54b9..09e35410 100644 --- a/converter/ppm/ppmtompeg/frame.c +++ b/converter/ppm/ppmtompeg/frame.c @@ -842,8 +842,6 @@ Frame_Resize(MpegFrame * const omf, exit(1); free(frameAP); - free(mf); } - diff --git a/converter/ppm/ppmtompeg/readframe.c b/converter/ppm/ppmtompeg/readframe.c index f085ca79..dcc02052 100644 --- a/converter/ppm/ppmtompeg/readframe.c +++ b/converter/ppm/ppmtompeg/readframe.c @@ -262,14 +262,11 @@ ReadFrameFile(MpegFrame * const frameP, const char * const conversion, bool * const eofP) { /*---------------------------------------------------------------------------- - Read a frame from the file 'ifP'. + Read a frame from the file 'ifP', doing adjustments as indicated. Return *eofP == TRUE iff we encounter EOF before we can get the frame. -----------------------------------------------------------------------------*/ - MpegFrame tempFrame; - MpegFrame * framePtr; - /* To make this code fit Netpbm properly, we should remove handling of all types except PNM and use pm_nextimage() to handle sensing of end of stream. @@ -278,17 +275,22 @@ ReadFrameFile(MpegFrame * const frameP, if (fileIsAtEnd(ifP)) *eofP = TRUE; else { + MpegFrame preResizeFrame; + /* The frame object that holds the frame before resizing */ + MpegFrame * rawFrameP; + /* The frame object with which we read in the raw frame */ + *eofP = FALSE; if (resizeFrame) { - tempFrame.inUse = FALSE; - tempFrame.orig_y = NULL; - tempFrame.y_blocks = NULL; - tempFrame.decoded_y = NULL; - tempFrame.halfX = NULL; - framePtr = &tempFrame; + preResizeFrame.inUse = FALSE; + preResizeFrame.orig_y = NULL; + preResizeFrame.y_blocks = NULL; + preResizeFrame.decoded_y = NULL; + preResizeFrame.halfX = NULL; + rawFrameP = &preResizeFrame; } else - framePtr = frameP; + rawFrameP = frameP; switch(baseFormat) { case YUV_FILE_TYPE: @@ -297,34 +299,35 @@ ReadFrameFile(MpegFrame * const frameP, if ((strncmp (yuvConversion, "EYUV", 4) == 0) || (strncmp (yuvConversion, "UCB", 3) == 0)) - ReadEYUV(framePtr, ifP, realWidth, realHeight); + ReadEYUV(rawFrameP, ifP, realWidth, realHeight); else /* Abekas-type (interlaced) YUV */ - ReadAYUV(framePtr, ifP, realWidth, realHeight); + ReadAYUV(rawFrameP, ifP, realWidth, realHeight); break; case Y_FILE_TYPE: - ReadY(framePtr, ifP, realWidth, realHeight); + ReadY(rawFrameP, ifP, realWidth, realHeight); break; case PNM_FILE_TYPE: - ReadPNM(framePtr, ifP); + ReadPNM(rawFrameP, ifP); break; case SUB4_FILE_TYPE: - ReadSub4(framePtr, ifP, yuvWidth, yuvHeight); + ReadSub4(rawFrameP, ifP, yuvWidth, yuvHeight); break; case JPEG_FILE_TYPE: case JMOVIE_FILE_TYPE: - ReadJPEG(framePtr, ifP); + ReadJPEG(rawFrameP, ifP); break; default: break; } - if (resizeFrame) - Frame_Resize(frameP, &tempFrame, Fsize_x, Fsize_y, + if (resizeFrame) { + assert(rawFrameP == &preResizeFrame); + Frame_Resize(frameP, &preResizeFrame, Fsize_x, Fsize_y, outputWidth, outputHeight); - + } if (GammaCorrection) DoGamma(frameP, Fsize_x, Fsize_y); diff --git a/doc/HISTORY b/doc/HISTORY index 04e7059c..8e1bf5d9 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -12,6 +12,9 @@ not yet BJH Release 11.00.01 -compression has never worked precisely either); should be fixed some day. + ppmtompeg: Fix crash with resize option because of invalid + memory free. + fitstopnm: fix invalid memory reference (nonterminated ASCIIZ string). |