Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Cabieces
otb
Commits
7194312e
Commit
7194312e
authored
10 years ago
by
Julien Michel
Browse files
Options
Downloads
Patches
Plain Diff
COV: Fixing coverity issues (unchecked dynamic cast)
parent
a8d07dfb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/IO/otbImageFileReader.txx
+21
-4
21 additions, 4 deletions
Code/IO/otbImageFileReader.txx
Code/IO/otbImageFileWriter.txx
+12
-1
12 additions, 1 deletion
Code/IO/otbImageFileWriter.txx
with
33 additions
and
5 deletions
Code/IO/otbImageFileReader.txx
+
21
−
4
View file @
7194312e
...
...
@@ -318,6 +318,15 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
{
typename GDALImageIO::Pointer imageIO = dynamic_cast<GDALImageIO*>(this->GetImageIO());
if(imageIO.IsNull())
{
otb::ImageFileReaderException e(__FILE__, __LINE__);
std::ostringstream msg;
msg << " ImageIO is of kind GDALImageIO, but fails to dynamic_cast (this should never happen)."<< std::endl;
e.SetDescription(msg.str().c_str());
throw e;
}
// Hint the IO whether the OTB image type takes complex pixels
// this will determine the strategy to fill up a vector image
OutputImagePixelType dummy;
...
...
@@ -728,8 +737,12 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
if (strcmp(this->m_ImageIO->GetNameOfClass(), "GDALImageIO") == 0)
{
typename GDALImageIO::Pointer imageIO = dynamic_cast<GDALImageIO*>(this->GetImageIO());
imageIO->GetResolutionInfo(res,desc);
return true;
if(imageIO.IsNotNull())
{
imageIO->GetResolutionInfo(res,desc);
return true;
}
}
#if defined(OTB_USE_JPEG2000)
...
...
@@ -737,8 +750,12 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
if (strcmp(this->m_ImageIO->GetNameOfClass(), "JPEG2000ImageIO") == 0)
{
typename JPEG2000ImageIO::Pointer imageIO = dynamic_cast<JPEG2000ImageIO*>(this->GetImageIO());
imageIO->GetResolutionInfo(res,desc);
return true;
if(imageIO.IsNotNull())
{
imageIO->GetResolutionInfo(res,desc);
return true;
}
}
#endif
...
...
This diff is collapsed.
Click to expand it.
Code/IO/otbImageFileWriter.txx
+
12
−
1
View file @
7194312e
...
...
@@ -452,7 +452,8 @@ ImageFileWriter<TInputImage>
i != allobjects.end(); ++i)
{
otb::ImageIOBase* io = dynamic_cast<otb::ImageIOBase*>(i->GetPointer());
msg << " " << io->GetNameOfClass() << std::endl;
if(io)
msg << " " << io->GetNameOfClass() << std::endl;
}
msg << " You probably failed to set a file suffix, or" << std::endl;
msg << " set the suffix to an unsupported type." << std::endl;
...
...
@@ -466,6 +467,16 @@ ImageFileWriter<TInputImage>
&& m_FilenameHelper->gdalCreationOptionsIsSet() )
{
typename GDALImageIO::Pointer imageIO = dynamic_cast<GDALImageIO*>(m_ImageIO.GetPointer());
if(imageIO.IsNull())
{
otb::ImageFileWriterException e(__FILE__, __LINE__);
std::ostringstream msg;
msg << " ImageIO is of kind GDALImageIO, but fails to dynamic_cast (this should never happen)."<< std::endl;
e.SetDescription(msg.str().c_str());
throw e;
}
imageIO->SetOptions(m_FilenameHelper->GetgdalCreationOptions());
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment