Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a4f64fc authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change Id5ba82a1 into eclair-mr2

* changes:
  Prevent getFile from copying when the file is too large.
parents d34f3994 d5ba82a1
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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;