From 9de89a6f6bd9e7635c41966a9ab4b8d818521e57 Mon Sep 17 00:00:00 2001 From: "stefan@webrtc.org" Date: Wed, 10 Jul 2013 12:42:15 +0000 Subject: [PATCH] Fix uninitialized value warning in rtp_payload_registry and make sure we return an error if the payload type isn't registered. R=pbos@webrtc.org, xians@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1782004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4321 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc | 1 + webrtc/voice_engine/channel.cc | 3 +++ 2 files changed, 4 insertions(+) diff --git a/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc b/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc index db56d789e..95e6bdc24 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc @@ -103,6 +103,7 @@ int32_t RTPPayloadRegistry::RegisterReceivePayload( if (ModuleRTPUtility::StringCompare(payload_name, "red", 3)) { red_payload_type_ = payload_type; payload = new ModuleRTPUtility::Payload; + memset(payload, 0, sizeof(*payload)); payload->audio = false; payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; strncpy(payload->name, payload_name, RTP_PAYLOAD_NAME_SIZE - 1); diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index fdd2f6ce4..6572f6976 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -2184,6 +2184,9 @@ int32_t Channel::ReceivedRTPPacket(const int8_t* data, int32_t length) { } header.payload_type_frequency = rtp_payload_registry_->GetPayloadTypeFrequency(header.payloadType); + if (header.payload_type_frequency < 0) { + return -1; + } bool retransmitted = IsPacketRetransmitted(header); bool in_order = rtp_receiver_->InOrderPacket(header.sequenceNumber); rtp_receive_statistics_->IncomingPacket(header, static_cast(length),