[glom] Document::add_file_to_archive(): Check the stat() return value.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Document::add_file_to_archive(): Check the stat() return value.
- Date: Thu, 4 Dec 2014 18:45:10 +0000 (UTC)
commit 9c5ff015ffd2dbf1bccf6a6732169b66b3729d32
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Dec 4 19:43:01 2014 +0100
Document::add_file_to_archive(): Check the stat() return value.
Found by Coverity Scan.
glom/libglom/document/document.cc | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 1cb6dcd..116de23 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -4916,7 +4916,12 @@ bool add_file_to_archive(archive* a, const std::string& parent_dir_path, const s
}
struct stat st;
- stat(filepath.c_str(), &st);
+ if(stat(filepath.c_str(), &st) < 0)
+ {
+ std::cerr << G_STRFUNC << ": stat() failed." << std::endl;
+ std::cerr << " : with path: " << filepath << std::endl;
+ return false;
+ }
struct archive_entry* entry = archive_entry_new();
ScopedArchiveEntryPtr<archive_entry> scoped_entry(entry, &archive_entry_free); //Make sure it is always
released.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]