Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Issue 3388024: Fix memory problem in DecoderVerbatim (Closed)

Created:
10 years, 2 months ago by Alpha Left Google
Modified:
9 years, 6 months ago
Reviewers:
ncarter (slow)
CC:
chromium-reviews, Alpha Left Google, Sergey Ulanov, dmac, awong, garykac, Paweł Hajdan Jr.
Base URL:
http://src.chromium.org/git/chromium.git
Visibility:
Public.

Description

Fix memory problem in DecoderVerbatim Change from c_str() to data() also did some boundary checks to make there's no memory error. BUG=None TEST=None Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=60746

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+15 lines, -3 lines) Patch
M remoting/base/decoder_verbatim.cc View 1 chunk +14 lines, -1 line 0 comments Download
M remoting/base/decoder_verbatim_unittest.cc View 1 chunk +1 line, -2 lines 0 comments Download

Messages

Total messages: 2 (0 generated)
Alpha Left Google
10 years, 2 months ago (2010-09-28 01:41:54 UTC) #1
ncarter (slow)
10 years, 2 months ago (2010-09-28 02:09:10 UTC) #2
LGTM

On Sep 27, 2010 6:42 PM, <hclam@chromium.org> wrote:
> Reviewers: ncarter,
>
> Description:
> Fix memory problem in DecoderVerbatim
>
> Change from c_str() to data() also did some boundary checks to make
there's
> no memory error.
>
> BUG=None
> TEST=None
>
> Please review this at http://codereview.chromium.org/3388024/show
>
> SVN Base: http://src.chromium.org/git/chromium.git
>
> Affected files:
> M remoting/base/decoder_verbatim.cc
> M remoting/base/decoder_verbatim_unittest.cc
>
>
> Index: remoting/base/decoder_verbatim.cc
> diff --git a/remoting/base/decoder_verbatim.cc
> b/remoting/base/decoder_verbatim.cc
> index
>
b944bbcaf15d6f9f68ae438104d431607de46c28..fd0b3d1070864b39df76f0dfc6cd4f74ae85d3ab

> 100644
> --- a/remoting/base/decoder_verbatim.cc
> +++ b/remoting/base/decoder_verbatim.cc
> @@ -102,7 +102,20 @@ bool
> DecoderVerbatim::HandleRectData(ChromotingHostMessage* message) {
> // Copy the data line by line.
> const int src_stride = bytes_per_pixel_ * rect_width_;
> const char* src =
> - message->update_stream_packet().rect_data().data().c_str();
> + message->update_stream_packet().rect_data().data().data();
> +
> + // Make sure there's enough data in |message|.
> + const int src_size =
> + message->update_stream_packet().rect_data().data().length();
> + if (src_size != src_stride * rect_height_)
> + return false;
> +
> + // Make sure there's enough space for us to write to.
> + if (frame_->height() < static_cast<size_t>(rect_height_) ||
> + frame_->stride(media::VideoFrame::kRGBPlane) < src_stride) {
> + return false;
> + }
> +
> int src_stride_dir = src_stride;
> if (reverse_rows_) {
> // Copy rows from bottom to top to flip the image vertically.
> Index: remoting/base/decoder_verbatim_unittest.cc
> diff --git a/remoting/base/decoder_verbatim_unittest.cc
> b/remoting/base/decoder_verbatim_unittest.cc
> index
>
8c00d7696d0c5d6211df9b251af7e92469734e94..af42e2736d8c3fcce3a665693f3ee9a087c97d57

> 100644
> --- a/remoting/base/decoder_verbatim_unittest.cc
> +++ b/remoting/base/decoder_verbatim_unittest.cc
> @@ -33,8 +33,7 @@ TEST(DecoderVerbatimTest, SimpleDecode) {
> begin_rect->set_pixel_format(PixelFormatAscii);
>
> // Prepare the rect data.
> - msg->mutable_update_stream_packet()->mutable_rect_data()->set_data(
> - kData, sizeof(kData));
> +
> msg->mutable_update_stream_packet()->mutable_rect_data()->set_data(kData);
>
> // Prepare the end rect.
> msg->mutable_update_stream_packet()->mutable_end_rect();
>
>

Powered by Google App Engine
This is Rietveld 408576698