am 5a4f64fc: Merge change Id5ba82a1 into eclair-mr2

Merge commit '5a4f64fcbf0382f33e9f79e6d0497113b972690e' into eclair-mr2-plus-aosp

* commit '5a4f64fcbf0382f33e9f79e6d0497113b972690e':
  Prevent getFile from copying when the file is too large.
This commit is contained in:
Leon Scroggins
2009-10-13 12:17:53 -07:00
committed by Android Git Automerger

View File

@@ -496,15 +496,18 @@ class BrowserFrame extends Handler {
* @param uri A String representing the URI of the desired file.
* @param buffer The byte array to copy the data into.
* @param offset The offet into buffer to place the data.
* @param expectSize The size that the buffer has allocated for this file.
* @return int The size of the given file, or zero if it fails.
*/
private int getFile(String uri, byte[] buffer, int offset) {
private int getFile(String uri, byte[] buffer, int offset,
int expectedSize) {
int size = 0;
try {
InputStream stream = mContext.getContentResolver()
.openInputStream(Uri.parse(uri));
size = stream.available();
if (buffer != null && buffer.length - offset >= size) {
if (size <= expectedSize && buffer != null
&& buffer.length - offset >= size) {
stream.read(buffer, offset, size);
} else {
size = 0;