diff options
author | Andy Hung <hunga@google.com> | 2015-09-01 20:07:56 +0000 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2015-09-02 17:52:12 +0000 |
commit | 25a634427dec455b79d73562131985ae85b98c43 (patch) | |
tree | 7eb4fe76d2239352ae39bf4ce75d7dc4f5e0d4bc /media | |
parent | f394f12167fddbc755855d06b615509517c99f14 (diff) | |
download | frameworks_av-25a634427dec455b79d73562131985ae85b98c43.zip frameworks_av-25a634427dec455b79d73562131985ae85b98c43.tar.gz frameworks_av-25a634427dec455b79d73562131985ae85b98c43.tar.bz2 |
Make IEffect command more robust (second try)
Bug: 23540907
Change-Id: If30cfa535ad51521053706fc40fc98d893db5bc7
(cherry picked from commit 10e6660cc5da65b027c90489ba7ac55d1504e012)
Diffstat (limited to 'media')
-rw-r--r-- | media/libmedia/IEffect.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/media/libmedia/IEffect.cpp b/media/libmedia/IEffect.cpp index 86c706a..1e54ca8 100644 --- a/media/libmedia/IEffect.cpp +++ b/media/libmedia/IEffect.cpp @@ -85,13 +85,15 @@ public: data.writeInt32(size); status_t status = remote()->transact(COMMAND, data, &reply); + if (status == NO_ERROR) { + status = reply.readInt32(); + } if (status != NO_ERROR) { if (pReplySize != NULL) *pReplySize = 0; return status; } - status = reply.readInt32(); size = reply.readInt32(); if (size != 0 && pReplyData != NULL && pReplySize != NULL) { reply.read(pReplyData, size); @@ -152,6 +154,10 @@ status_t BnEffect::onTransact( char *cmd = NULL; if (cmdSize) { cmd = (char *)calloc(cmdSize, 1); + if (cmd == NULL) { + reply->writeInt32(NO_MEMORY); + return NO_ERROR; + } data.read(cmd, cmdSize); } uint32_t replySize = data.readInt32(); @@ -159,15 +165,22 @@ status_t BnEffect::onTransact( char *resp = NULL; if (replySize) { resp = (char *)calloc(replySize, 1); + if (resp == NULL) { + free(cmd); + reply->writeInt32(NO_MEMORY); + return NO_ERROR; + } } status_t status = command(cmdCode, cmdSize, cmd, &replySz, resp); reply->writeInt32(status); - if (replySz < replySize) { - replySize = replySz; - } - reply->writeInt32(replySize); - if (replySize) { - reply->write(resp, replySize); + if (status == NO_ERROR) { + if (replySz < replySize) { + replySize = replySz; + } + reply->writeInt32(replySize); + if (replySize) { + reply->write(resp, replySize); + } } if (cmd) { free(cmd); |