Fixed memory leakage in the DRM framework

Change-Id: Ib1276bec6cafb4e94f8f13b52e50e4987765eec4
This commit is contained in:
Hung Nguyen
2012-06-05 13:19:53 +02:00
committed by James Dong
parent 13f7fe763b
commit 0bf43848ad
3 changed files with 11 additions and 6 deletions

View File

@@ -190,8 +190,9 @@ DrmConstraints* BpDrmManagerService::getConstraints(
if (0 < bufferSize) {
data = new char[bufferSize];
reply.read(data, bufferSize);
}
drmConstraints->put(&key, data);
delete[] data;
}
}
}
return drmConstraints;
@@ -219,8 +220,9 @@ DrmMetadata* BpDrmManagerService::getMetadata(int uniqueId, const String8* path)
if (0 < bufferSize) {
data = new char[bufferSize];
reply.read(data, bufferSize);
}
drmMetadata->put(&key, data);
delete[] data;
}
}
}
return drmMetadata;
@@ -889,9 +891,11 @@ status_t BnDrmManagerService::onTransact(
int bufferSize = 0;
if (NULL != value) {
bufferSize = strlen(value);
}
reply->writeInt32(bufferSize + 1);
reply->write(value, bufferSize + 1);
} else {
reply->writeInt32(0);
}
}
}
delete drmConstraints; drmConstraints = NULL;

View File

@@ -47,7 +47,7 @@ String8 ReadWriteUtils::readBytes(const String8& filePath) {
if (length == read(fd, (void*) bytes, length)) {
string.append(bytes, length);
}
delete bytes;
delete[] bytes;
}
fclose(file);
}

View File

@@ -65,10 +65,11 @@ DrmConstraints* DrmPassthruPlugIn::onGetConstraints(
char* charValue = NULL;
charValue = new char[value.length() + 1];
strncpy(charValue, value.string(), value.length());
charValue[value.length()] = '\0';
//Just add dummy available time for verification
drmConstraints->put(&(DrmConstraints::LICENSE_AVAILABLE_TIME), charValue);
delete[] charValue;
return drmConstraints;
}