am dc7eb9c9: am 00cfbe82: am a5608acb: Merge "Don\'t allow MemoryFiles of negative length."

* commit 'dc7eb9c947f36cbd34021663845bcbb090c3169d':
  Don't allow MemoryFiles of negative length.
This commit is contained in:
Narayan Kamath
2014-04-09 12:20:01 +00:00
committed by Android Git Automerger

View File

@@ -63,12 +63,17 @@ public class MemoryFile
* Allocates a new ashmem region. The region is initially not purgable.
*
* @param name optional name for the file (can be null).
* @param length of the memory file in bytes.
* @param length of the memory file in bytes, must be non-negative.
* @throws IOException if the memory file could not be created.
*/
public MemoryFile(String name, int length) throws IOException {
mLength = length;
mFD = native_open(name, length);
if (length >= 0) {
mFD = native_open(name, length);
} else {
throw new IOException("Invalid length: " + length);
}
if (length > 0) {
mAddress = native_mmap(mFD, length, PROT_READ | PROT_WRITE);
} else {