PLUGINS/src/osddemo/osddemo.c: fix possible null pointer dereference

Message ID 1301864455.12068.32.camel@mattotaupa
State New
Headers

Commit Message

Paul Menzel April 3, 2011, 9 p.m. UTC
  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(-)
  

Patch

diff --git a/PLUGINS/src/osddemo/osddemo.c b/PLUGINS/src/osddemo/osddemo.c
index 2e6a33b..d3ec718 100644
--- a/PLUGINS/src/osddemo/osddemo.c
+++ b/PLUGINS/src/osddemo/osddemo.c
@@ -267,7 +267,9 @@  void cTrueColorDemo::Action(void)
                              }
                           Start = cTimeMs::Now();
                           StartLine = Line;
-                          Line += NextPixmap->DrawPort().Height();
+                          if (NextPixmap) {
+                             Line += NextPixmap->DrawPort().Height();
+                             }
                           }
                        State++;
                      }