From ed739c59f5ad6c26302f06b8de002ff052e26b25 Mon Sep 17 00:00:00 2001 From: Emux Date: Tue, 14 Jul 2020 15:00:49 +0300 Subject: [PATCH] ReadBuffer.readFromFile: handle byte allocation --- .../org/oscim/tiling/source/mapfile/ReadBuffer.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vtm/src/org/oscim/tiling/source/mapfile/ReadBuffer.java b/vtm/src/org/oscim/tiling/source/mapfile/ReadBuffer.java index f516439c..0e565c5e 100644 --- a/vtm/src/org/oscim/tiling/source/mapfile/ReadBuffer.java +++ b/vtm/src/org/oscim/tiling/source/mapfile/ReadBuffer.java @@ -1,6 +1,6 @@ /* * Copyright 2010, 2011, 2012 mapsforge.org - * Copyright 2017-2018 devemux86 + * Copyright 2017-2020 devemux86 * Copyright 2017 Gustl22 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). @@ -27,6 +27,7 @@ import java.io.RandomAccessFile; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -84,7 +85,12 @@ public class ReadBuffer { LOG.warning("invalid read length: " + length); return false; } - mBufferData = new byte[length]; + try { + mBufferData = new byte[length]; + } catch (Throwable t) { + LOG.log(Level.SEVERE, t.getMessage(), t); + return false; + } } mBufferPosition = 0;