Skip to content

Commit 915f4c5

Browse files
committed
Code security and fix bug
1 parent 99585e3 commit 915f4c5

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

p2pconn/StreamingDesktop/RemoteDesktop.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ private static void GetCursorState()
161161
if (GetCursorInfo(out pci))
162162
{
163163
IntPtr htcursor = pci.hCursor;
164-
Cursor micursor = null;
165-
micursor = new Cursor(htcursor);
166-
Tipo = micursor.ToString();
164+
using (var micursor = new Cursor(htcursor))
165+
{
166+
Tipo = micursor.ToString();
167+
}
167168
}
168169
}
169170
catch // (Exception ex)

p2pconn/StreamingDesktop/ScreenCaptureStream.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,10 @@ private void WorkerThread( )
370370
catch ( Exception exception )
371371
{
372372
// provide information to clients
373-
if ( VideoSourceError != null )
373+
VideoSourceErrorEventHandler videoSrcHandler = VideoSourceError;
374+
if ( videoSrcHandler != null )
374375
{
375-
VideoSourceError( this, new VideoSourceErrorEventArgs( exception.Message ) );
376+
videoSrcHandler( this, new VideoSourceErrorEventArgs( exception.Message ) );
376377
}
377378
// wait for a while before the next try
378379
Thread.Sleep( 250 );
@@ -387,9 +388,10 @@ private void WorkerThread( )
387388
graphics.Dispose( );
388389
bitmap.Dispose( );
389390

390-
if ( PlayingFinished != null )
391+
PlayingFinishedEventHandler handler = PlayingFinished;
392+
if ( handler != null )
391393
{
392-
PlayingFinished( this, ReasonToFinishPlaying.StoppedByUser );
394+
handler( this, ReasonToFinishPlaying.StoppedByUser );
393395
}
394396
}
395397
}

p2pconn/UdtSharpLib/Queue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ static void worker(object param)
735735
ulong ctime = currtime - 100000 * Timer.getCPUFrequency();
736736
for (int i = 0; i < self.m_pRcvUList.m_nodeList.Count; ++i)
737737
{
738-
RNode ul = self.m_pRcvUList.m_nodeList[0];
738+
RNode ul = self.m_pRcvUList.m_nodeList[i];
739739
if (ul.m_llTimeStamp >= ctime)
740740
break;
741741

p2pconn/UdtSharpLib/UdtSocket.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public UdtSocket Accept()
6767
{
6868
IPEndPoint clientEndPoint = null;
6969
int clientSocketId = UDT.s_UDTUnited.accept(mSocketId, ref clientEndPoint);
70-
if (clientSocketId == UDT.INVALID_SOCK)
71-
return null;
7270

7371
return new UdtSocket(clientSocketId, clientEndPoint, mLocalEndPoint);
7472
}

0 commit comments

Comments
 (0)