Skip to content

Commit

Permalink
[core] Explicitly compare with enum type.
Browse files Browse the repository at this point in the history
Fixes #2374.
  • Loading branch information
maxsharabayko committed Jun 15, 2022
1 parent 61170ad commit 2de9e6e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7561,7 +7561,7 @@ bool srt::CUDT::updateCC(ETransmissionEvent evt, const EventVariant arg)
EInitEvent only_input = arg.get<EventVariant::INIT>();
// false = TEV_INIT_RESET: in the beginning, or when MAXBW was changed.

if (only_input && m_config.llMaxBW)
if (only_input != TEV_INIT_RESET && m_config.llMaxBW)
{
HLOGC(rslog.Debug, log << CONID() << "updateCC/TEV_INIT: non-RESET stage and m_config.llMaxBW already set to " << m_config.llMaxBW);
// Don't change
Expand Down Expand Up @@ -9705,7 +9705,7 @@ bool srt::CUDT::packUniqueData(CPacket& w_packet, time_point& w_origintime)
// Note that the packet header must have a valid seqno set, as it is used as a counter for encryption.
// Other fields of the data packet header (e.g. timestamp, destination socket ID) are not used for the counter.
// Cypher may change packet length!
if (m_pCryptoControl->encrypt((w_packet)))
if (m_pCryptoControl->encrypt((w_packet)) != ENCS_CLEAR)
{
// Encryption failed
//>>Add stats for crypto failure
Expand Down Expand Up @@ -10165,7 +10165,7 @@ int srt::CUDT::processData(CUnit* in_unit)
{
IF_HEAVY_LOGGING(exc_type = "ACCEPTED");
excessive = false;
if (u->m_Packet.getMsgCryptoFlags())
if (u->m_Packet.getMsgCryptoFlags() != EK_NOENC)
{
EncryptionStatus rc = m_pCryptoControl ? m_pCryptoControl->decrypt((u->m_Packet)) : ENCS_NOTSUP;
if (rc != ENCS_CLEAR)
Expand Down
3 changes: 1 addition & 2 deletions srtcore/fec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1472,8 +1472,7 @@ void FECFilterBuiltin::RcvRebuild(Group& g, int32_t seqno, Group::Type tp)
if (tp == Group::SINGLE)
return;

// This flips HORIZ/VERT
Group::Type crosstype = Group::Type(!tp);
Group::Type crosstype = Group::FlipType(tp);
EHangStatus stat;

if (crosstype == Group::HORIZ)
Expand Down
6 changes: 6 additions & 0 deletions srtcore/fec.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ class FECFilterBuiltin: public SrtPacketFilterBase
SINGLE // Horizontal-only with no recursion
};

static Type FlipType(Type t)
{
SRT_ASSERT(t != SINGLE);
return (t == HORIZ) ? VERT : HORIZ;
}

};

struct RcvGroup: Group
Expand Down

0 comments on commit 2de9e6e

Please sign in to comment.