From 38715910ea552ad5198b6dba8bca3a57f46c1e9a Mon Sep 17 00:00:00 2001 From: "derat@chromium.org" Date: Mon, 24 Feb 2014 15:59:40 +0000 Subject: chromeos: Make dbus::MessageReader memory ownership explicit Make memory returned by MessageReader::PopArrayOfBytes() const to make it clearer that ownership remains with the MessageReader. Also update PopArrayOfStrings() and PopArrayOfObjectPaths() to clear the passed-in vectors before appending to them. BUG=none TBR=isherman@chromium.org,mvanouwerkerk@chromium.org Review URL: https://codereview.chromium.org/176693003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252922 0039d316-1c4b-4281-b951-d872f2087c98 --- chromeos/dbus/cryptohome_client.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'chromeos/dbus/cryptohome_client.cc') diff --git a/chromeos/dbus/cryptohome_client.cc b/chromeos/dbus/cryptohome_client.cc index f0bbd18..c58ea20 100644 --- a/chromeos/dbus/cryptohome_client.cc +++ b/chromeos/dbus/cryptohome_client.cc @@ -357,7 +357,7 @@ class CryptohomeClientImpl : public CryptohomeClient { if (!response.get()) return false; dbus::MessageReader reader(response.get()); - uint8* bytes = NULL; + const uint8* bytes = NULL; size_t length = 0; if (!reader.PopArrayOfBytes(&bytes, &length) || !reader.PopBool(successful)) @@ -737,7 +737,7 @@ class CryptohomeClientImpl : public CryptohomeClient { return; } dbus::MessageReader reader(response); - uint8* bytes = NULL; + const uint8* bytes = NULL; size_t length = 0; if (!reader.PopArrayOfBytes(&bytes, &length)) { callback.Run(DBUS_METHOD_CALL_FAILURE, std::vector()); @@ -827,7 +827,7 @@ class CryptohomeClientImpl : public CryptohomeClient { return; } dbus::MessageReader reader(response); - uint8* data_buffer = NULL; + const uint8* data_buffer = NULL; size_t data_length = 0; bool result = false; if (!reader.PopArrayOfBytes(&data_buffer, &data_length) || @@ -835,7 +835,7 @@ class CryptohomeClientImpl : public CryptohomeClient { callback.Run(DBUS_METHOD_CALL_FAILURE, false, std::string()); return; } - std::string data(reinterpret_cast(data_buffer), data_length); + std::string data(reinterpret_cast(data_buffer), data_length); callback.Run(DBUS_METHOD_CALL_SUCCESS, result, data); } @@ -900,7 +900,7 @@ class CryptohomeClientImpl : public CryptohomeClient { dbus::MessageReader reader(signal); int async_id = 0; bool return_status = false; - uint8* return_data_buffer = NULL; + const uint8* return_data_buffer = NULL; size_t return_data_length = 0; if (!reader.PopInt32(&async_id) || !reader.PopBool(&return_status) || @@ -909,7 +909,7 @@ class CryptohomeClientImpl : public CryptohomeClient { return; } if (!async_call_status_data_handler_.is_null()) { - std::string return_data(reinterpret_cast(return_data_buffer), + std::string return_data(reinterpret_cast(return_data_buffer), return_data_length); async_call_status_data_handler_.Run(async_id, return_status, return_data); } -- cgit v1.1