Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to reduce problems identified by static analysis #4113

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Jan 17, 2024

  • pngoutput.cpp: Catch possible exceptions.
  • printinfo.cpp: assertions to assure we don't dereference a null pointer.
  • testtex.cpp: make sure allocated chunk is initialized
  • WriterInternal.h: Catch condition that could lead to buffer underflow.
  • imagebufalgo_mad.cpp: Simplify pointless clause. The prior test was redundant. Since a few lines above, if B was an image but A was not, we swapped to ensure that A was always an image. So here, we can just test A to know for sure that at least one of them is an image. That makes the test here simpler, but it also makes it more clear to static analysis that from this point forward, A can't be nullptr.

* pngoutput.cpp: Catch possible exceptions.
* printinfo.cpp: assertions to assure we don't dereference a null pointer.
* testtex.cpp: make sure allocated chunk is initialized
* WriterInternal.h: Catch condition that could lead to buffer underflow.
* imagebufalgo_mad.cpp: Simplify pointless clause. The prior test was
  redundant. Since a few lines above, if B was an image but A was not,
  we swapped to ensure that A was always an image. So here, we can
  just test A to know for sure that at least one of them is an
  image. That makes the test here simpler, but it also makes it more
  clear to static analysis that from this point forward, A can't be
  nullptr.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz
Copy link
Collaborator Author

lgritz commented Jan 17, 2024

This is a reposting of botched PR #4112. Please see there for the review discussion and approval.

@lgritz lgritz merged commit cfb7918 into AcademySoftwareFoundation:master Jan 17, 2024
24 of 25 checks passed
@lgritz lgritz deleted the lg-sonar-1 branch January 17, 2024 06:42
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Jan 21, 2024
…reFoundation#4113)

* pngoutput.cpp: Catch possible exceptions.
* printinfo.cpp: assertions to assure we don't dereference a null
pointer.
* testtex.cpp: make sure allocated chunk is initialized
* WriterInternal.h: Catch condition that could lead to buffer underflow.
* imagebufalgo_mad.cpp: Simplify pointless clause. The prior test was
redundant. Since a few lines above, if B was an image but A was not, we
swapped to ensure that A was always an image. So here, we can just test
A to know for sure that at least one of them is an image. That makes the
test here simpler, but it also makes it more clear to static analysis
that from this point forward, A can't be nullptr.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
1div0 pushed a commit to 1div0/OpenImageIO that referenced this pull request Feb 24, 2024
…reFoundation#4113)

* pngoutput.cpp: Catch possible exceptions.
* printinfo.cpp: assertions to assure we don't dereference a null
pointer.
* testtex.cpp: make sure allocated chunk is initialized
* WriterInternal.h: Catch condition that could lead to buffer underflow.
* imagebufalgo_mad.cpp: Simplify pointless clause. The prior test was
redundant. Since a few lines above, if B was an image but A was not, we
swapped to ensure that A was always an image. So here, we can just test
A to know for sure that at least one of them is an image. That makes the
test here simpler, but it also makes it more clear to static analysis
that from this point forward, A can't be nullptr.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
Signed-off-by: Peter Kovář <peter.kovar@reflexion.tv>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant