Skip to content
This repository
Browse code

fix null ptr dereference of GUIDialogCache. fixes #14065.

  • Loading branch information...
commit e28aed30bbfc0da6972a50a8a8d42c41c9468253 1 parent e008bad
authored February 07, 2013

Showing 1 changed file with 42 additions and 22 deletions. Show diff stats Hide diff stats

  1. 64  xbmc/dialogs/GUIDialogCache.cpp
64  xbmc/dialogs/GUIDialogCache.cpp
@@ -30,16 +30,20 @@
30 30
 
31 31
 CGUIDialogCache::CGUIDialogCache(DWORD dwDelay, const CStdString& strHeader, const CStdString& strMsg) : CThread("CGUIDialogCache")
32 32
 {
  33
+  m_strHeader = strHeader;
  34
+  m_strLinePrev = strMsg;
  35
+  bSentCancel = false;
  36
+  dwDelay = 0;
  37
+
33 38
   m_pDlg = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
34 39
 
  40
+  if (!m_pDlg)
  41
+    return;
  42
+
35 43
   /* if progress dialog is already running, take it over */
36 44
   if( m_pDlg->IsDialogRunning() )
37 45
     dwDelay = 0;
38 46
 
39  
-  m_strHeader = strHeader;
40  
-  m_strLinePrev = strMsg;
41  
-  bSentCancel = false;
42  
-
43 47
   if(dwDelay == 0)
44 48
     OpenDialog();    
45 49
   else
@@ -54,7 +58,7 @@ void CGUIDialogCache::Close(bool bForceClose)
54 58
 
55 59
   // we cannot wait for the app thread to process the close message
56 60
   // as this might happen during player startup which leads to a deadlock
57  
-  if (m_pDlg->IsDialogRunning())
  61
+  if (m_pDlg && m_pDlg->IsDialogRunning())
58 62
     CApplicationMessenger::Get().Close(m_pDlg,bForceClose,false);
59 63
 
60 64
   //Set stop, this will kill this object, when thread stops  
@@ -63,19 +67,22 @@ void CGUIDialogCache::Close(bool bForceClose)
63 67
 
64 68
 CGUIDialogCache::~CGUIDialogCache()
65 69
 {
66  
-  if(m_pDlg->IsDialogRunning())
  70
+  if(m_pDlg && m_pDlg->IsDialogRunning())
67 71
     m_pDlg->Close();
68 72
 }
69 73
 
70 74
 void CGUIDialogCache::OpenDialog()
71  
-{  
72  
-  if (m_strHeader.IsEmpty())
73  
-    m_pDlg->SetHeading(438);
74  
-  else
75  
-    m_pDlg->SetHeading(m_strHeader);
  75
+{
  76
+  if (m_pDlg)
  77
+  {
  78
+    if (m_strHeader.IsEmpty())
  79
+      m_pDlg->SetHeading(438);
  80
+    else
  81
+      m_pDlg->SetHeading(m_strHeader);
76 82
 
77  
-  m_pDlg->SetLine(2, m_strLinePrev);
78  
-  m_pDlg->StartModal();
  83
+    m_pDlg->SetLine(2, m_strLinePrev);
  84
+    m_pDlg->StartModal();
  85
+  }
79 86
   bSentCancel = false;
80 87
 }
81 88
 
@@ -91,17 +98,23 @@ void CGUIDialogCache::SetHeader(int nHeader)
91 98
 
92 99
 void CGUIDialogCache::SetMessage(const CStdString& strMessage)
93 100
 {
94  
-  m_pDlg->SetLine(0, m_strLinePrev2);
95  
-  m_pDlg->SetLine(1, m_strLinePrev);
96  
-  m_pDlg->SetLine(2, strMessage);
  101
+  if (m_pDlg)
  102
+  {
  103
+    m_pDlg->SetLine(0, m_strLinePrev2);
  104
+    m_pDlg->SetLine(1, m_strLinePrev);
  105
+    m_pDlg->SetLine(2, strMessage);
  106
+  }
97 107
   m_strLinePrev2 = m_strLinePrev;
98 108
   m_strLinePrev = strMessage; 
99 109
 }
100 110
 
101 111
 bool CGUIDialogCache::OnFileCallback(void* pContext, int ipercent, float avgSpeed)
102 112
 {
103  
-  m_pDlg->ShowProgressBar(true);
104  
-  m_pDlg->SetPercentage(ipercent); 
  113
+  if (m_pDlg)
  114
+  {
  115
+    m_pDlg->ShowProgressBar(true);
  116
+    m_pDlg->SetPercentage(ipercent);
  117
+  }
105 118
 
106 119
   if( IsCanceled() ) 
107 120
     return false;
@@ -111,6 +124,9 @@ bool CGUIDialogCache::OnFileCallback(void* pContext, int ipercent, float avgSpee
111 124
 
112 125
 void CGUIDialogCache::Process()
113 126
 {
  127
+  if (m_pDlg)
  128
+    return;
  129
+
114 130
   while( true )
115 131
   {
116 132
     
@@ -147,16 +163,20 @@ void CGUIDialogCache::Process()
147 163
 }
148 164
 
149 165
 void CGUIDialogCache::ShowProgressBar(bool bOnOff) 
150  
-{ 
151  
-  m_pDlg->ShowProgressBar(bOnOff); 
  166
+{
  167
+  if (m_pDlg)
  168
+    m_pDlg->ShowProgressBar(bOnOff);
152 169
 }
  170
+
153 171
 void CGUIDialogCache::SetPercentage(int iPercentage) 
154 172
 { 
155  
-  m_pDlg->SetPercentage(iPercentage); 
  173
+  if (m_pDlg)
  174
+    m_pDlg->SetPercentage(iPercentage);
156 175
 }
  176
+
157 177
 bool CGUIDialogCache::IsCanceled() const
158 178
 {
159  
-  if (m_pDlg->IsDialogRunning())
  179
+  if (m_pDlg && m_pDlg->IsDialogRunning())
160 180
     return m_pDlg->IsCanceled();
161 181
   else
162 182
     return false;

0 notes on commit e28aed3

Please sign in to comment.
Something went wrong with that request. Please try again.