Skip to content

Commit

Permalink
Added a check whether all components in a scan are actually present.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Richter committed May 30, 2022
1 parent 920542b commit ea63151
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions codestream/entropyparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
** This class represents the interface for parsing the
** entropy coded data in JPEG as part of a single scan.
**
** $Id: entropyparser.cpp,v 1.24 2021/09/08 10:30:06 thor Exp $
** $Id: entropyparser.cpp,v 1.25 2022/05/30 14:05:58 thor Exp $
**
*/

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

// The residual scan uses all components here, not just for, but
// The residual scan uses all components here, not just four, but
// it does not require the component count either.
for(volatile UBYTE i = 0;i < m_ucCount && i < 4;i++) {
JPG_TRY {
Expand Down
10 changes: 9 additions & 1 deletion marker/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
**
** Represents all data in a single scan, and hence is the SOS marker.
**
** $Id: scan.cpp,v 1.117 2021/11/15 07:39:43 thor Exp $
** $Id: scan.cpp,v 1.118 2022/05/30 14:06:11 thor Exp $
**
*/

Expand Down Expand Up @@ -338,6 +338,14 @@ void Scan::CreateParser(void)
//
assert(m_pParser == NULL);
//
// Check whether all components are there.
for(UBYTE i = 0;i < m_ucCount && i < 4;i++) {
if (ComponentOf(i) == NULL) {
JPG_THROW(MALFORMED_STREAM,"Scan::CreateParser",
"found a component ID in a scan that does not exist");
}
}
//
switch(type) {
case Baseline:
m_pParser = new(m_pEnviron) class SequentialScan(m_pFrame,this,
Expand Down

0 comments on commit ea63151

Please sign in to comment.