Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2018-06-14 16:33:04 +0300
committerArsentiy Milchakov <milcars@mapswithme.com>2018-06-21 15:05:58 +0300
commit222a75ff67e65a31058ba63136d4b2b3c9ce8591 (patch)
treee86751a0ca504894acae70b20df6f9bf5b5d2490 /local_ads
parent1728f1af3df2f6c927c88085845353f2c7c19f73 (diff)
[coding] FileReader now always throws exception on an out-of-bounds access.
Diffstat (limited to 'local_ads')
-rw-r--r--local_ads/local_ads_tests/file_helpers_tests.cpp9
-rw-r--r--local_ads/statistics.cpp8
2 files changed, 11 insertions, 6 deletions
diff --git a/local_ads/local_ads_tests/file_helpers_tests.cpp b/local_ads/local_ads_tests/file_helpers_tests.cpp
index 408b677abf..9ffa141e28 100644
--- a/local_ads/local_ads_tests/file_helpers_tests.cpp
+++ b/local_ads/local_ads_tests/file_helpers_tests.cpp
@@ -22,7 +22,8 @@ UNIT_TEST(LocalAdsHelpers_Read_Write_Country_Name)
string result;
{
- FileReader reader(testFile.GetFullPath());
+ FileReader reader(testFile.GetFullPath(), FileReader::kDefaultLogPageSize,
+ FileReader::kDefaultLogPageCount);
ReaderSource<FileReader> src(reader);
result = ReadCountryName(src);
}
@@ -44,7 +45,8 @@ UNIT_TEST(LocalAdsHelpers_Read_Write_Timestamp)
local_ads::Timestamp resultInHours;
local_ads::Timestamp resultInSeconds;
{
- FileReader reader(testFile.GetFullPath());
+ FileReader reader(testFile.GetFullPath(), FileReader::kDefaultLogPageSize,
+ FileReader::kDefaultLogPageCount);
ReaderSource<FileReader> src(reader);
resultInHours = ReadTimestamp<chrono::hours>(src);
resultInSeconds = ReadTimestamp<chrono::seconds>(src);
@@ -66,7 +68,8 @@ UNIT_TEST(LocalAdsHelpers_Read_Write_RawData)
vector<uint8_t> result;
{
- FileReader reader(testFile.GetFullPath());
+ FileReader reader(testFile.GetFullPath(), FileReader::kDefaultLogPageSize,
+ FileReader::kDefaultLogPageCount);
ReaderSource<FileReader> src(reader);
result = ReadRawData(src);
}
diff --git a/local_ads/statistics.cpp b/local_ads/statistics.cpp
index 4ec9529b91..b582042d7a 100644
--- a/local_ads/statistics.cpp
+++ b/local_ads/statistics.cpp
@@ -157,7 +157,7 @@ std::list<local_ads::Event> ReadEvents(std::string const & fileName)
try
{
- FileReader reader(fileName, true /* withExceptions */);
+ FileReader reader(fileName, FileReader::kDefaultLogPageSize, FileReader::kDefaultLogPageCount);
ReaderSource<FileReader> src(reader);
ReadPackedData(src, [&result](local_ads::Statistics::PackedData && data,
std::string const & countryId, int64_t mwmVersion,
@@ -464,7 +464,8 @@ void Statistics::ExtractMetadata(std::string const & fileName)
int64_t mwmVersion;
Timestamp baseTimestamp;
{
- FileReader reader(fileName, true /* withExceptions */);
+ FileReader reader(fileName, FileReader::kDefaultLogPageSize,
+ FileReader::kDefaultLogPageCount);
ReaderSource<FileReader> src(reader);
ReadMetadata(src, countryId, mwmVersion, baseTimestamp);
}
@@ -492,7 +493,8 @@ void Statistics::BalanceMemory()
uint64_t totalSize = 0;
for (auto const & metadata : m_metadataCache)
{
- FileReader reader(metadata.second.m_fileName);
+ FileReader reader(metadata.second.m_fileName, FileReader::kDefaultLogPageSize,
+ FileReader::kDefaultLogPageCount);
sizeInBytes[metadata.first] = reader.Size();
totalSize += reader.Size();
}