Skip to content

Commit ea63151

Browse files
author
Thomas Richter
committed
Added a check whether all components in a scan are actually present.
1 parent 920542b commit ea63151

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Diff for: codestream/entropyparser.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
** This class represents the interface for parsing the
4444
** entropy coded data in JPEG as part of a single scan.
4545
**
46-
** $Id: entropyparser.cpp,v 1.24 2021/09/08 10:30:06 thor Exp $
46+
** $Id: entropyparser.cpp,v 1.25 2022/05/30 14:05:58 thor Exp $
4747
**
4848
*/
4949

@@ -62,7 +62,7 @@ EntropyParser::EntropyParser(class Frame *frame,class Scan *scan)
6262
{
6363
m_ucCount = scan->ComponentsInScan();
6464

65-
// The residual scan uses all components here, not just for, but
65+
// The residual scan uses all components here, not just four, but
6666
// it does not require the component count either.
6767
for(volatile UBYTE i = 0;i < m_ucCount && i < 4;i++) {
6868
JPG_TRY {

Diff for: marker/scan.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
**
4343
** Represents all data in a single scan, and hence is the SOS marker.
4444
**
45-
** $Id: scan.cpp,v 1.117 2021/11/15 07:39:43 thor Exp $
45+
** $Id: scan.cpp,v 1.118 2022/05/30 14:06:11 thor Exp $
4646
**
4747
*/
4848

@@ -338,6 +338,14 @@ void Scan::CreateParser(void)
338338
//
339339
assert(m_pParser == NULL);
340340
//
341+
// Check whether all components are there.
342+
for(UBYTE i = 0;i < m_ucCount && i < 4;i++) {
343+
if (ComponentOf(i) == NULL) {
344+
JPG_THROW(MALFORMED_STREAM,"Scan::CreateParser",
345+
"found a component ID in a scan that does not exist");
346+
}
347+
}
348+
//
341349
switch(type) {
342350
case Baseline:
343351
m_pParser = new(m_pEnviron) class SequentialScan(m_pFrame,this,

0 commit comments

Comments
 (0)