Reland "Replace RTPHeader memset with assignment from a fresh object."

This is a reland of 50686460caad4d13283c550df01690316e7cb934

Original change's description:
> Replace RTPHeader memset with assignment from a fresh object.
> 
> Since RTPHeader contains std::string members, memset results in
> undefined behavior, with memory leaks being the best case.
> 
> Bug: chromium:945598
> Change-Id: I5c04e6b2fb08816fc036abfbb6ba7aaf19469687
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/129720
> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#27282}

Bug: chromium:945598
Change-Id: Id75c1fa022575b76a1b03f1213f5017d158d9c2d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/128875
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27290}
This commit is contained in:
Niels Möller
2019-03-26 13:14:30 +01:00
committed by Commit Bot
parent a58e169269
commit a533e00fa0
2 changed files with 2 additions and 14 deletions

View File

@ -163,19 +163,7 @@ bool Packet::ParseHeader(const RtpHeaderParser& parser) {
} }
void Packet::CopyToHeader(RTPHeader* destination) const { void Packet::CopyToHeader(RTPHeader* destination) const {
destination->markerBit = header_.markerBit; *destination = header_;
destination->payloadType = header_.payloadType;
destination->sequenceNumber = header_.sequenceNumber;
destination->timestamp = header_.timestamp;
destination->ssrc = header_.ssrc;
destination->numCSRCs = header_.numCSRCs;
destination->paddingLength = header_.paddingLength;
destination->headerLength = header_.headerLength;
destination->payload_type_frequency = header_.payload_type_frequency;
memcpy(&destination->arrOfCSRCs, &header_.arrOfCSRCs,
sizeof(header_.arrOfCSRCs));
memcpy(&destination->extension, &header_.extension,
sizeof(header_.extension));
} }
} // namespace test } // namespace test

View File

@ -64,7 +64,7 @@ bool RtpHeaderParserImpl::Parse(const uint8_t* packet,
size_t length, size_t length,
RTPHeader* header) const { RTPHeader* header) const {
RtpUtility::RtpHeaderParser rtp_parser(packet, length); RtpUtility::RtpHeaderParser rtp_parser(packet, length);
memset(header, 0, sizeof(*header)); *header = RTPHeader();
RtpHeaderExtensionMap map; RtpHeaderExtensionMap map;
{ {