TJBench: Fix errors when decomp. files w/ ICC data

Embedded ICC profiles can cause the size of a JPEG file to exceed the
size returned by tjBufSize() (which is really meant to be used for
compression anyhow, not for decompression), and this was causing a
segfault (C) or an ArrayIndexOutOfBoundsException (Java) when
decompressing such files with TJBench.  This commit modifies the
benchmark such that, when tiled decompression is disabled, it re-uses
the source buffer as the primary JPEG buffer.
This commit is contained in:
DRC
2017-06-26 20:48:02 -05:00
parent 301ba4f305
commit 11eec4a398
2 changed files with 6 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2009-2014, 2016 D. R. Commander. All Rights Reserved.
* Copyright (C)2009-2014, 2016-2017 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -582,8 +582,8 @@ class TJBench {
System.out.print("N/A N/A ");
jpegBuf = new byte[1][TJ.bufSize(_tilew, _tileh, subsamp)];
jpegSize = new int[1];
jpegBuf[0] = srcBuf;
jpegSize[0] = srcSize;
System.arraycopy(srcBuf, 0, jpegBuf[0], 0, srcSize);
}
if (w == tilew)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2009-2016 D. R. Commander. All Rights Reserved.
* Copyright (C)2009-2017 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -668,7 +668,9 @@ int decompTest(char *filename)
{
if(quiet==1) printf("N/A N/A ");
jpegsize[0]=srcsize;
memcpy(jpegbuf[0], srcbuf, srcsize);
free(jpegbuf[0]);
jpegbuf[0]=srcbuf;
srcbuf=NULL;
}
if(w==tilew) _tilew=_w;