Skip to content

Commit

Permalink
Merge pull request #68 from mdaus/jpegDecompressorFix
Browse files Browse the repository at this point in the history
Properly initialize JPEG decompression control
  • Loading branch information
asylvest authored Dec 19, 2017
2 parents 6075d27 + 823f2b3 commit 0180a0b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions modules/c/jpeg/source/LibjpegDecompress.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* =========================================================================
* This file is part of NITRO
* =========================================================================
*
*
* (C) Copyright 2004 - 2014, MDA Information Systems LLC
*
* NITRO is free software; you can redistribute it and/or modify
Expand All @@ -14,8 +14,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, If not,
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, If not,
* see <http://www.gnu.org/licenses/>.
*
*/
Expand Down Expand Up @@ -944,7 +944,7 @@ NITFPRIV(NITF_BOOL) scanOffsets(nitf_IOInterface* io,

/* Well this is what I wanted to happen, although I didnt have
the guts to ask for it in the while loop, since I have seen
some pretty unfortunate JPEGs in NITF files
some pretty unfortunate JPEGs in NITF files
*/
if (bytesRead != fileLength)
{
Expand Down Expand Up @@ -976,7 +976,10 @@ NITFPRIV(nitf_DecompressionControl*) implOpen(nitf_ImageSubheader* subheader,
NITF_ERR_DECOMPRESSION);
return NULL;
}

implControl->ioInterface = NULL;
implControl->markerList = NULL;
implControl->quantTable = NULL;
implControl->length = 0;
return (nitf_DecompressionControl*)implControl;
}

Expand Down Expand Up @@ -1263,7 +1266,7 @@ NITFPRIV(NITF_BOOL) findBlockSOI(JPEGImplControl* control,
nitf_ListIterator_increment(&x))
{
JPEGMarkerItem* item = (JPEGMarkerItem*)nitf_ListIterator_get(&x);
if (strcmp(item->name, "SOI") == 0 &&
if (strcmp(item->name, "SOI") == 0 &&
((j = item->block) == blockNumber))
{
*soi = item->off - 2;
Expand Down Expand Up @@ -1294,7 +1297,7 @@ NITFPRIV(nitf_Uint8*) implReadBlock(nitf_DecompressionControl* control,
{
/*
* For now, do as I say (to test that you dont break anything in
* the trivial case
* the trivial case
*/
NITF_BOOL separateBands = 0;

Expand Down Expand Up @@ -1481,6 +1484,11 @@ NITFPRIV(void) implClose(nitf_DecompressionControl** control)
{
nitf_List_destruct(&implControl->markerList);
}
/* delete quant table */
if (implControl && implControl->quantTable)
{
free(implControl->quantTable);
}
if (implControl)
{
NITF_FREE(implControl);
Expand Down

0 comments on commit 0180a0b

Please sign in to comment.