From 3f727c0ea3ad1de512c935c6e80423f2115b46c0 Mon Sep 17 00:00:00 2001 From: Hyejin Kim Date: Sat, 9 Mar 2013 11:28:54 +0900 Subject: [PATCH] fix mem leak on error handling Change-Id: I40d8e371c46184aa701fa676246201a9d8f6e27d --- libs/binder/Parcel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 8f7f7e76d..c7bdcbca4 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -1472,6 +1472,8 @@ status_t Parcel::continueWrite(size_t desired) if (objectsSize) { objects = (size_t*)malloc(objectsSize*sizeof(size_t)); if (!objects) { + free(data); + mError = NO_MEMORY; return NO_MEMORY; } @@ -1552,7 +1554,7 @@ status_t Parcel::continueWrite(size_t desired) mError = NO_MEMORY; return NO_MEMORY; } - + if(!(mDataCapacity == 0 && mObjects == NULL && mObjectsCapacity == 0)) { ALOGE("continueWrite: %d/%p/%d/%d", mDataCapacity, mObjects, mObjectsCapacity, desired);