diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-15 23:02:59 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-15 23:02:59 +0000 |
commit | bbf4400222e3b4eec801780aefe025d74aa9a339 (patch) | |
tree | a608cad1a2029a85cc0bf085d9a6601ab91e9709 /remoting | |
parent | 4bdf4b98cdd0b85243dace4696086082c104ad84 (diff) | |
download | chromium_src-bbf4400222e3b4eec801780aefe025d74aa9a339.zip chromium_src-bbf4400222e3b4eec801780aefe025d74aa9a339.tar.gz chromium_src-bbf4400222e3b4eec801780aefe025d74aa9a339.tar.bz2 |
Coverity: Fix leak in ChromotingClient::read_image.
Also, use scoped_array instead of scoped_ptr.
BUG=none
CID=10905
TEST=builds
Review URL: http://codereview.chromium.org/2844005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49854 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/client/plugin/chromotocol.h | 2 | ||||
-rw-r--r-- | remoting/client/plugin/client.cc | 11 |
2 files changed, 5 insertions, 8 deletions
diff --git a/remoting/client/plugin/chromotocol.h b/remoting/client/plugin/chromotocol.h index 9a35351..8199630 100644 --- a/remoting/client/plugin/chromotocol.h +++ b/remoting/client/plugin/chromotocol.h @@ -71,7 +71,7 @@ struct BinaryImageHeader { struct BinaryImage { BinaryImageHeader header; - scoped_ptr<char> data; + scoped_array<char> data; }; } // namespace remoting diff --git a/remoting/client/plugin/client.cc b/remoting/client/plugin/client.cc index 75e236c8..e8db3dc 100644 --- a/remoting/client/plugin/client.cc +++ b/remoting/client/plugin/client.cc @@ -328,8 +328,8 @@ bool ChromotingClient::read_image(BinaryImage* image) { return false; } - char* raw_data = new char[image->header.size]; - result = host_->read_data(raw_data, image->header.size); + scoped_array<char> raw_data(new char[image->header.size]); + result = host_->read_data(raw_data.get(), image->header.size); if (!result) { std::cout << "Failed to receive image data" << std::endl; return false; @@ -337,7 +337,7 @@ bool ChromotingClient::read_image(BinaryImage* image) { if (image->header.format == FormatRaw) { // Raw image - all we need to do is load the data, so we're done. - image->data.reset(raw_data); + image->data.reset(raw_data.release()); return true; } else if (image->header.format == FormatVp8) { return false; @@ -348,7 +348,7 @@ bool ChromotingClient::read_image(BinaryImage* image) { uint8* planes[3]; int strides[3]; printf("decoder.DecodeFrame\n"); - if (!decoder.DecodeFrame(raw_data, image->header.size)) { + if (!decoder.DecodeFrame(raw_data.get(), image->header.size)) { std::cout << "Unable to decode frame" << std::endl; return false; } @@ -378,9 +378,6 @@ bool ChromotingClient::read_image(BinaryImage* image) { printf("conversion done\n"); image->data.reset(rgb_data); - - // Raw YUV data is no longer needed. - delete raw_data; return true; #endif } |