Return false in SharedFiles::open() when an error happens

This commit is contained in:
Wenfeng Liu 2018-05-24 01:10:01 +00:00 committed by Felipe Zimmerle
parent a02bd3a3b9
commit 45e531236a
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277

View File

@ -127,6 +127,7 @@ err_fh:
bool SharedFiles::open(const std::string& fileName, std::string *error) {
std::pair<msc_file_handler *, FILE *> a;
bool ret = true;
#if MODSEC_USE_GENERAL_LOCK
pthread_mutex_lock(m_generalLock);
@ -136,11 +137,13 @@ bool SharedFiles::open(const std::string& fileName, std::string *error) {
if (a.first == NULL) {
a = add_new_handler(fileName, error);
if (error->size() > 0) {
ret = false;
goto out;
}
}
if (a.first == NULL) {
error->assign("Not able to open: " + fileName);
ret = false;
goto out;
}
@ -149,7 +152,7 @@ out:
pthread_mutex_unlock(m_generalLock);
#endif
return true;
return ret;
}