Skip to content

Commit 45e5312

Browse files
Wenfeng LiuFelipe Zimmerle
authored andcommitted
Return false in SharedFiles::open() when an error happens
1 parent a02bd3a commit 45e5312

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/utils/shared_files.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ std::pair<msc_file_handler *, FILE *> SharedFiles::add_new_handler(
127127

128128
bool SharedFiles::open(const std::string& fileName, std::string *error) {
129129
std::pair<msc_file_handler *, FILE *> a;
130+
bool ret = true;
130131

131132
#if MODSEC_USE_GENERAL_LOCK
132133
pthread_mutex_lock(m_generalLock);
@@ -136,11 +137,13 @@ bool SharedFiles::open(const std::string& fileName, std::string *error) {
136137
if (a.first == NULL) {
137138
a = add_new_handler(fileName, error);
138139
if (error->size() > 0) {
140+
ret = false;
139141
goto out;
140142
}
141143
}
142144
if (a.first == NULL) {
143145
error->assign("Not able to open: " + fileName);
146+
ret = false;
144147
goto out;
145148
}
146149

@@ -149,7 +152,7 @@ bool SharedFiles::open(const std::string& fileName, std::string *error) {
149152
pthread_mutex_unlock(m_generalLock);
150153
#endif
151154

152-
return true;
155+
return ret;
153156
}
154157

155158

0 commit comments

Comments
 (0)