diff --git a/platform/android/asset_request_baton.cpp b/platform/android/asset_request_baton.cpp index 30819e506..a0349b9f6 100644 --- a/platform/android/asset_request_baton.cpp +++ b/platform/android/asset_request_baton.cpp @@ -53,7 +53,7 @@ void AssetRequestBaton::run(uv_async_t *async) { int error = 0; ptr->apk = zip_open(mbgl::android::apk_path.c_str(), 0, &error); - if (ptr->apk == nullptr || ptr->canceled || !ptr->request) { + if ((ptr->apk == nullptr) || ptr->canceled || !ptr->request) { // Opening the APK failed or was canceled. There isn't much left we can do. const int message_size = zip_error_to_str(nullptr, 0, error, errno); const std::unique_ptr message = boost::make_unique(message_size); @@ -65,7 +65,7 @@ void AssetRequestBaton::run(uv_async_t *async) { std::string apk_file_path = "assets/" + ptr->path; ptr->apk_file = zip_fopen(ptr->apk, apk_file_path.c_str(), ZIP_FL_NOCASE); - if (ptr->apk_file == nullptr || ptr->canceled || !ptr->request) { + if ((ptr->apk_file == nullptr) || ptr->canceled || !ptr->request) { // Opening the asset failed or was canceled. We already have an open file handle // though, which we'll have to close. zip_error_get(ptr->apk, &error, nullptr); @@ -77,7 +77,7 @@ void AssetRequestBaton::run(uv_async_t *async) { } struct zip_stat stat; - if (zip_stat(ptr->apk, apk_file_path.c_str(), ZIP_FL_NOCASE, &stat) != 0 || + if ((zip_stat(ptr->apk, apk_file_path.c_str(), ZIP_FL_NOCASE, &stat) != 0) || ptr->canceled || !ptr->request) { // Stating failed or was canceled. We already have an open file handle // though, which we'll have to close. @@ -90,9 +90,9 @@ void AssetRequestBaton::run(uv_async_t *async) { return; } - const std::unique_ptr body = boost::make_unique(stat.size); + const std::unique_ptr data = boost::make_unique(stat.size); - if (zip_fread(ptr->apk_file, reinterpret_cast(body.get()), stat.size) == -1 || + if (static_cast(zip_fread(ptr->apk_file, reinterpret_cast(data.get()), stat.size)) != stat.size || ptr->canceled || !ptr->request) { // Reading failed or was canceled. We already have an open file handle // though, which we'll have to close. @@ -108,7 +108,8 @@ void AssetRequestBaton::run(uv_async_t *async) { if (ptr->request) { ptr->request->response = std::unique_ptr(new Response); ptr->request->response->code = 200; - ptr->request->response->data = body.get(); + std::string body(data.get(), stat.size); + ptr->request->response->data = body; ptr->request->notify(); } diff --git a/platform/default/http_request_baton_curl.cpp b/platform/default/http_request_baton_curl.cpp index ffd352cfe..a5b0edbbf 100644 --- a/platform/default/http_request_baton_curl.cpp +++ b/platform/default/http_request_baton_curl.cpp @@ -448,7 +448,7 @@ static CURLcode sslctx_function(CURL */*curl*/, void *sslctx, void */*parm*/) { const std::unique_ptr pem = boost::make_unique(stat.size); - if (zip_fread(apk_file, reinterpret_cast(pem.get()), stat.size) == -1) { + if (static_cast(zip_fread(apk_file, reinterpret_cast(pem.get()), stat.size)) != stat.size) { zip_fclose(apk_file); apk_file = nullptr; zip_close(apk); diff --git a/src/style/style.cpp b/src/style/style.cpp index aa5b15088..c398f9d59 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -91,6 +92,7 @@ void Style::loadJSON(const uint8_t *const data) { rapidjson::Document doc; doc.Parse<0>((const char *const)data); if (doc.HasParseError()) { + Log::Error(Event::ParseStyle, "Error parsing style JSON at %i: %s", doc.GetErrorOffset(), doc.GetParseError()); throw error::style_parse(doc.GetErrorOffset(), doc.GetParseError()); }