OSDN Git Service

Fix ordering assumption of argument evaluation.
authorGloria Wang <gwang@google.com>
Mon, 1 Aug 2011 21:01:29 +0000 (14:01 -0700)
committerGloria Wang <gwang@google.com>
Mon, 1 Aug 2011 21:01:29 +0000 (14:01 -0700)
No specific order is specified in the C++ standard, but the order of
the calls to Parcel read commands matters.  Move any calls with multiple
reads to local variables.

Fix for bug 5104979.

Change-Id: I709aa040e990d2659e7a3a089f7a42ae812de9ff

media/libmedia/IMediaPlayer.cpp

index 76a8a91..52885d2 100644 (file)
@@ -352,7 +352,9 @@ status_t BnMediaPlayer::onTransact(
         } break;
         case SET_VOLUME: {
             CHECK_INTERFACE(IMediaPlayer, data, reply);
-            reply->writeInt32(setVolume(data.readFloat(), data.readFloat()));
+            float leftVolume = data.readFloat();
+            float rightVolume = data.readFloat();
+            reply->writeInt32(setVolume(leftVolume, rightVolume));
             return NO_ERROR;
         } break;
         case INVOKE: {
@@ -367,7 +369,9 @@ status_t BnMediaPlayer::onTransact(
         } break;
         case GET_METADATA: {
             CHECK_INTERFACE(IMediaPlayer, data, reply);
-            const status_t retcode = getMetadata(data.readInt32(), data.readInt32(), reply);
+            bool update_only = static_cast<bool>(data.readInt32());
+            bool apply_filter = static_cast<bool>(data.readInt32());
+            const status_t retcode = getMetadata(update_only, apply_filter, reply);
             reply->setDataPosition(0);
             reply->writeInt32(retcode);
             reply->setDataPosition(0);