From 60bb3f49c92d75306acd75a42fe500b3a9da5ed2 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 15 Jan 2018 11:54:21 -0800 Subject: [PATCH] Fix crash on 0 size assets --- android/app/src/main/cpp/native.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/android/app/src/main/cpp/native.cpp b/android/app/src/main/cpp/native.cpp index c6e3ee2070..13daf4c471 100644 --- a/android/app/src/main/cpp/native.cpp +++ b/android/app/src/main/cpp/native.cpp @@ -79,11 +79,13 @@ void copyAsset(const char* sourceAsset, const QString& destFilename) { if (!file.resize(size)) { throw std::runtime_error("Unable to resize output file"); } - auto mapped = file.map(0, size); - if (!mapped) { - throw std::runtime_error("Unable to map output file"); + if (size != 0) { + auto mapped = file.map(0, size); + if (!mapped) { + throw std::runtime_error("Unable to map output file"); + } + memcpy(mapped, data, size); } - memcpy(mapped, data, size); file.close(); }); }