PLUGINS/src/osddemo/osddemo.c: fix possible null pointer dereference
Commit Message
Date: Sun, 3 Apr 2011 22:53:33 +0200
Cppcheck reports the following.
$ cppcheck --version
Cppcheck 1.47
$ cppcheck .
[…]
Checking ./PLUGINS/src/osddemo/osddemo.c...
[./PLUGINS/src/osddemo/osddemo.c:8]: (debug) Include file: "vdr/osd.h" not found.
[./PLUGINS/src/osddemo/osddemo.c:9]: (debug) Include file: "vdr/plugin.h" not found.
[./PLUGINS/src/osddemo/osddemo.c:270]: (error) Possible null pointer dereference: NextPixmap
[…]
`CreateTextPixmap` can indeed assign `NULL` to `NextPixmap` and right before in line 265 the same check is performed.
Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net>
CC: Klaus Schmidinger <Klaus.Schmidinger@tvdr.de>
---
PLUGINS/src/osddemo/osddemo.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
@@ -267,7 +267,9 @@ void cTrueColorDemo::Action(void)
}
Start = cTimeMs::Now();
StartLine = Line;
- Line += NextPixmap->DrawPort().Height();
+ if (NextPixmap) {
+ Line += NextPixmap->DrawPort().Height();
+ }
}
State++;
}