download: Check for empty filename
Avoid an unhandled std::out_of_range exception if the client provides
an empty filename.
Change-Id: Ibfc99eee9adada255052375581bb308f7afa9da4
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/download_manager.cpp b/download_manager.cpp
index d600cf4..e6f7728 100644
--- a/download_manager.cpp
+++ b/download_manager.cpp
@@ -27,9 +27,12 @@
{
// Sanitize the fileName string
- fileName.erase(std::remove(fileName.begin(), fileName.end(), '/'),
- fileName.end());
- fileName = fileName.substr(fileName.find_first_not_of('.'));
+ if (!fileName.empty())
+ {
+ fileName.erase(std::remove(fileName.begin(), fileName.end(), '/'),
+ fileName.end());
+ fileName = fileName.substr(fileName.find_first_not_of('.'));
+ }
if (fileName.empty())
{