Ticket #7016: libs_libmythui-pointer-checks

File libs_libmythui-pointer-checks, 1.5 KB (added by Erik Hovland <erik@…>, 11 years ago)

Check pointers before using them

Line 
1Make sure pointers are valid.
2
3From: Erik Hovland <erik@hovland.org>
4
5
6---
7
8 mythtv/libs/libmythui/lirc_client.c       |    2 +-
9 mythtv/libs/libmythui/mythuistatetype.cpp |    4 ++--
10 2 files changed, 3 insertions(+), 3 deletions(-)
11
12
13diff --git a/mythtv/libs/libmythui/lirc_client.c b/mythtv/libs/libmythui/lirc_client.c
14index f7a701a..1bd1f05 100644
15--- a/mythtv/libs/libmythui/lirc_client.c
16+++ b/mythtv/libs/libmythui/lirc_client.c
17@@ -1360,7 +1360,7 @@ static int lirc_readconfig_only_internal(const struct lirc_state *state,
18        {
19                *config=NULL;
20                lirc_freeconfigentries(first);
21-               if(*sha_bang!=NULL)
22+               if(sha_bang && *sha_bang!=NULL)
23                {
24                        free(*sha_bang);
25                        *sha_bang=NULL;
26diff --git a/mythtv/libs/libmythui/mythuistatetype.cpp b/mythtv/libs/libmythui/mythuistatetype.cpp
27index eca510a..17980c5 100644
28--- a/mythtv/libs/libmythui/mythuistatetype.cpp
29+++ b/mythtv/libs/libmythui/mythuistatetype.cpp
30@@ -110,7 +110,7 @@ bool MythUIStateType::DisplayState(const QString &name)
31     {
32         if (m_ShowEmpty || m_CurrentState != NULL)
33         {
34-            if (m_deferload)
35+            if (m_CurrentState && m_deferload)
36                 m_CurrentState->LoadNow();
37 
38             if (old)
39@@ -137,7 +137,7 @@ bool MythUIStateType::DisplayState(StateType type)
40     {
41         if (m_ShowEmpty || m_CurrentState != NULL)
42         {
43-            if (m_deferload)
44+            if (m_CurrentState && m_deferload)
45                 m_CurrentState->LoadNow();
46 
47             if (m_CurrentState)