[Live-devel] Possible bug
owen at metamachine.com
owen at metamachine.com
Tue Sep 4 08:37:14 PDT 2012
In liveMedia/RTSPServer.cpp, on line 1252, there's a multi clause if
statement that, as formatted, looks like you want it to be evaluated in a
way that precedence rules say you will get a surprise.
The line looks like this:
if (streamingMode == RTP_TCP && rtpChannelId == 0xFF ||
streamingMode != RTP_TCP && ourClientConnection->fClientOutputSocket
!= ourClientConnection->fClientInputSocket) {...}
It looks like you expect it to be evaluated like this:
if ((streamingMode == RTP_TCP && rtpChannelId == 0xFF || streamingMode !=
RTP_TCP) && (ourClientConnection->fClientOutputSocket !=
ourClientConnection->fClientInputSocket)) {...}
The compiler will actually give you this:
if ((streamingMode == RTP_TCP && rtpChannelId == 0xFF) || (streamingMode
!= RTP_TCP && ourClientConnection->fClientOutputSocket !=
ourClientConnection->fClientInputSocket)) {...}
because && has slightly higher precedence than ||.
// Wally, hopefully not wasting your time.
More information about the live-devel
mailing list