List Info

Thread: CN -- avoid null dereferences in hxclientkit




CN -- avoid null dereferences in hxclientkit
user name
2006-11-02 01:55:24
Cool, thanks. Committed to head & 150Cay.

--Bob

At 05:47 PM 11/1/2006, Daniel Yek wrote:
>That looks great. Thanks Bob.
>
>
>--
>Daniel Yek
>
>
>At 05:32 PM 11/1/2006, you wrote:
>>On the Mac, not all of the Client Engine Callbacks
are filled in. (This 
>>is an interesting problem which I will look into
later.) Meanwhile, I 
>>want to avoid dereferencing NULL.
>>
>>I've also changed the member variable name to
reflect that it's a pointer.
>>
>>I would like to commit this to 150Cay and HEAD.
>>
>>I am a RealNetworks employee.
>>
>>--Bob
>>
>>
>>Index: src/CHXClientPlayer.cpp
>>====================================================
===============
>>RCS file:
/cvsroot/player/hxclientkit/src/CHXClientPlayer.cpp,v
>>retrieving revision 1.35.2.4
>>diff -u -w -r1.35.2.4 CHXClientPlayer.cpp
>>--- src/CHXClientPlayer.cpp     27 Oct 2006 19:37:17
-0000      1.35.2.4
>>+++ src/CHXClientPlayer.cpp     2 Nov 2006 01:29:34
-0000
>> -251,14 +251,17 
>>          SPIHXAudioPlayer spAudioPlayer =
m_pIHXCorePlayer;
>>          if ( spAudioPlayer.IsValid() )
>>          {
>>-            m_ClientEngineCallbacks = 
>>CHXClientEngine::GetClientEngineCallbacks();
>>+            m_pClientEngineCallbacks = 
>>CHXClientEngine::GetClientEngineCallbacks();
>>
>>-            if
(m_ClientEngineCallbacks->ReadPreference("volume&quo
t;, NULL, 
>>sizeof(buf), &uUsedBufferLength))
>>+            if (m_pClientEngineCallbacks &&

>>m_pClientEngineCallbacks->ReadPreference)
>>              {
>>-               
m_ClientEngineCallbacks->ReadPreference("volume"
;, buf, 
>>sizeof(buf), &uUsedBufferLength);
>>+                if
(m_pClientEngineCallbacks->ReadPreference("volume&qu
ot;, 
>>NULL, sizeof(buf), &uUsedBufferLength))
>>+                {
>>+                   
m_pClientEngineCallbacks->ReadPreference("volume&quo
t;, 
>>buf, sizeof(buf), &uUsedBufferLength);
>>                  buf[3] = '';
>>                  volume = atoi((const char *)buf);
>>              }
>>+            }
>>
>>              // XXXSEH: GetDeviceVolume() affects
the entire 
>> application, but its effects are instant.
>>              // GetAudioVolume() affects each
player instance 
>> separately, but their effect is delayed.
>> -1197,10 +1200,12 
>>          {
>>                  m_pIClientVolume->SetVolume(
volume );
>>
>>-
>>+                if (m_pClientEngineCallbacks
&& 
>>m_pClientEngineCallbacks->WritePreference)
>>+                {
>>                  snprintf((char*)buf, sizeof(buf),
"%i", volume);
>>                  buf[3] = '';
>>-               
m_ClientEngineCallbacks->WritePreference("volume&quo
t;, buf, 
>>sizeof(buf));
>>+                   
m_pClientEngineCallbacks->WritePreference("volume&qu
ot;, 
>>buf, sizeof(buf));
>>+                }
>>          }
>>  }
>>
>>Index: src/CHXClientPlayer.h
>>====================================================
===============
>>RCS file:
/cvsroot/player/hxclientkit/src/CHXClientPlayer.h,v
>>retrieving revision 1.19.6.4
>>diff -u -w -r1.19.6.4 CHXClientPlayer.h
>>--- src/CHXClientPlayer.h       27 Oct 2006 19:37:17
-0000      1.19.6.4
>>+++ src/CHXClientPlayer.h       2 Nov 2006 01:29:34
-0000
>> -125,7 +125,7 
>>
>>      bool Init( HXxWindow* pHXxWindow, void*
userInfo, const 
>> HXClientCallbacks* pClientCallbacks );
>>
>>-    const HXClientEngineCallbacks*
m_ClientEngineCallbacks;  // This is 
>>a struct.
>>+    const HXClientEngineCallbacks*
m_pClientEngineCallbacks;
>>
>>  public:
>>
>
>
>_______________________________________________
>Player-dev mailing list
>Player-devhelixcommunity.org
>http://lists.helixcommunity.org/mailman/listinfo/play
er-dev



_______________________________________________
Player-dev mailing list
Player-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/play
er-dev
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )