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:
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@@ -582,8 +582,8 @@ class TJBench {
|
|||||||
System.out.print("N/A N/A ");
|
System.out.print("N/A N/A ");
|
||||||
jpegBuf = new byte[1][TJ.bufSize(_tilew, _tileh, subsamp)];
|
jpegBuf = new byte[1][TJ.bufSize(_tilew, _tileh, subsamp)];
|
||||||
jpegSize = new int[1];
|
jpegSize = new int[1];
|
||||||
|
jpegBuf[0] = srcBuf;
|
||||||
jpegSize[0] = srcSize;
|
jpegSize[0] = srcSize;
|
||||||
System.arraycopy(srcBuf, 0, jpegBuf[0], 0, srcSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w == tilew)
|
if (w == tilew)
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* 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 ");
|
if(quiet==1) printf("N/A N/A ");
|
||||||
jpegsize[0]=srcsize;
|
jpegsize[0]=srcsize;
|
||||||
memcpy(jpegbuf[0], srcbuf, srcsize);
|
free(jpegbuf[0]);
|
||||||
|
jpegbuf[0]=srcbuf;
|
||||||
|
srcbuf=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(w==tilew) _tilew=_w;
|
if(w==tilew) _tilew=_w;
|
||||||
|
|||||||
Reference in New Issue
Block a user