From e2c32e9f966cf9f2c9ed94bf0703344a2cca284b Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Mon, 21 Mar 2011 14:16:03 -0700 Subject: [PATCH] If nothing is to be copied, return right away. This avoids a potential out-of-bounds problem in the code below. Change-Id: I942d55da0a5288b37512cb74407f900a2d824c0c related-to-bug: 4139974 --- media/libstagefright/NuCachedSource2.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp index c7b99b9bf4bf2..248b67806c36d 100644 --- a/media/libstagefright/NuCachedSource2.cpp +++ b/media/libstagefright/NuCachedSource2.cpp @@ -135,6 +135,10 @@ size_t PageCache::releaseFromStart(size_t maxBytes) { void PageCache::copy(size_t from, void *data, size_t size) { LOGV("copy from %d size %d", from, size); + if (size == 0) { + return; + } + CHECK_LE(from + size, mTotalSize); size_t offset = 0;