svace fix 63/183163/1 accepted/tizen/unified/20180704.154022 submit/tizen/20180704.010647
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Tue, 3 Jul 2018 05:00:06 +0000 (14:00 +0900)
committersanghyeok.oh <sanghyeok.oh@samsung.com>
Tue, 3 Jul 2018 05:21:50 +0000 (14:21 +0900)
Change-Id: Ib6b047eb6fe90476d6c28980589ed7eb777eb4e5
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
src/internal/xml_parser.cpp

index 60aa5ad..ddb360b 100644 (file)
@@ -206,9 +206,16 @@ std::unique_ptr<char[]> file2str(const std::string& filename) {
                throw std::runtime_error(std::string("Failed to open file: ").append(filename).c_str());
        }
 
-       fseek(fp, 0, SEEK_END);
+       if (fseek(fp, 0, SEEK_END)) {
+               throw std::runtime_error(std::string("Failed to fseek end of file").c_str());
+       }
        long fsize = ftell(fp);
-       fseek(fp, 0, SEEK_SET); //rewind
+       if (fsize < 0) {
+               throw std::runtime_error(std::string("Failed to ftell").c_str());
+       }
+       if (fseek(fp, 0, SEEK_SET)) {
+               throw std::runtime_error(std::string("Failed to fseek beginning of file").c_str());
+       }
 
        auto str = std::unique_ptr<char[]>(new char[fsize + 1]);        // TODO change to make_unique when c++14 becomes available
        const int count = 1;