summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaket Dumbre <97769119+sacdintel@users.noreply.github.com>2023-03-22 15:38:12 -0700
committerGitHub <noreply@github.com>2023-03-22 15:38:12 -0700
commit41b40f8412f9587cccac88f4520cb6ede512e5ae (patch)
treef83d0262e153455984a92184e7d687865b227f3f
parentb93300b237825e1e12e13052a6067a6bf22ab429 (diff)
parent770653e3ba67c30a629ca7d12e352d83c2541b1e (diff)
downloadacpica-41b40f8412f9587cccac88f4520cb6ede512e5ae.tar.gz
Merge pull request #845 from tamird/ub-zero-offset-null-pointer
Avoid undefined behavior: applying zero offset to null pointer
-rw-r--r--source/components/dispatcher/dswstate.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/source/components/dispatcher/dswstate.c b/source/components/dispatcher/dswstate.c
index f761ceb80..cc648e3ae 100644
--- a/source/components/dispatcher/dswstate.c
+++ b/source/components/dispatcher/dswstate.c
@@ -785,9 +785,14 @@ AcpiDsInitAmlWalk (
WalkState->ParserState.Aml =
- WalkState->ParserState.AmlStart = AmlStart;
+ WalkState->ParserState.AmlStart =
WalkState->ParserState.AmlEnd =
- WalkState->ParserState.PkgEnd = AmlStart + AmlLength;
+ WalkState->ParserState.PkgEnd = AmlStart;
+ /* Avoid undefined behavior: applying zero offset to null pointer */
+ if (AmlLength != 0) {
+ WalkState->ParserState.AmlEnd += AmlLength;
+ WalkState->ParserState.PkgEnd += AmlLength;
+ }
/* The NextOp of the NextWalk will be the beginning of the method */